Answers for "argument functions in javascript"

27

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
Posted by: Guest on July-09-2020
1

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
Posted by: Guest on September-07-2021
0

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'
Posted by: Guest on January-07-2021
0

argument functions in javascript

function hello(name) {
  alert("Hello " + name);
}
var name = "Person";
hello();
Posted by: Guest on September-13-2021

Code answers related to "argument functions in javascript"

Code answers related to "Javascript"

Browse Popular Code Answers by Language