Answers for "how to access any argument in javascript"

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

arguments object in javascript

function test(a, b, c){
    // console.log(arguments);
    // console.log(JSON.stringify(arguments));
    // console.log(typeof a);

    // var sum = 0;
    // for (var i = 0; i<arguments.length; i++){
    //     sum += arguments[i];
    // }
    // console.log(sum);

    //for (var i = 0; i<arguments.length; i++){
    //    console.log(arguments[i]);
    //}
  
    console.log(arguments[0]);
}

test(10, 20, 30);
Posted by: Guest on December-19-2020

Code answers related to "how to access any argument in javascript"

Code answers related to "Javascript"

Browse Popular Code Answers by Language