javascript function variable arguments
function foo() {
for (var i = 0; i < arguments.length; i++) {
console.log(arguments[i]);
}
}
foo(1,2,3);
//1
//2
//3
javascript function variable arguments
function foo() {
for (var i = 0; i < arguments.length; i++) {
console.log(arguments[i]);
}
}
foo(1,2,3);
//1
//2
//3
javascript function arguments
function add() {
var sum = 0;
for (var i = 0, j = arguments.length; i < j; i++) {
sum += arguments[i];
}
return sum;
}
add(2, 3, 4, 5); // 14
how to access any argument in javascript
function example() {
console.log(arguments);
console.log(arguments[0]);
} // Console outputs an array of each argument with its value
example('hi', 'hello');
// Outputs:
// ['hi', 'hello']
// 'hi'
argument functions in javascript
function hello(name) {
alert("Hello " + name);
}
var name = "Person";
hello();
Copyright © 2021 Codeinu
Forgot your account's password or having trouble logging into your Account? Don't worry, we'll help you to get back your account. Enter your email address and we'll send you a recovery link to reset your password. If you are experiencing problems resetting your password contact us