Finding the Factorial using Recursion
Finding the Factorial using Recursion in javascript.
function factorial(x) {
if(x <= 1) return 1;
return x*factorial(x-1);
}
factorial(5);
Finding the Factorial using Recursion in javascript.
function factorial(x) {
if(x <= 1) return 1;
return x*factorial(x-1);
}
factorial(5);
Creating Chainable interfaces in javascript…
(function() {
function _init() {
return this;
}
_init.prototype = {
"myFunction": function() {
return this;
}
// Put all the functions here - make sure all 'return this;'
}
chainer = function() {
return new _init();
}
})();
Roll out your own JavaScript Interfaces
[tags][/tags]
The command to execute a javascript file using rhino.
java -jar /path/to/custom_rhino.jar JS_File.js
Get Custom Rhino(From Dojo Library)
Find the position of an element using javascript
function findPos(obj) {
var curleft = curtop = 0;
if (obj.offsetParent) {
curleft = obj.offsetLeft
curtop = obj.offsetTop
while (obj = obj.offsetParent) {
curleft += obj.offsetLeft
curtop += obj.offsetTop
}
}
return [curleft,curtop];
}