javascript parameters object code example
Example 1: arguments object in javascript
var sum = 0;
function addAll(){
for (var i = 0; i<arguments.length; i++){
sum+=arguments[i];
}
console.log(sum);
}
addAll(1, 2, 3, 4, 5, 6, 7, 8, 9,10);
Example 2: arguments object in javascript
function test(a, b, c){
console.log(arguments[0]);
}
test(10, 20, 30);
Example 3: object as a parameter in javascript
var fac = function me(n) {
if (n > 0) {
return n * me(n-1);
} else {
return 1;
}
};
console.log(fac(3));