+ 1

function hello() { console.log(arguments[0]); console.log(+Array.isArray(arguments)); } hello(5);

Please explain this question Answer of this code is 5 0

15th Aug 2023, 1:40 AM
Aman Kumar
Aman Kumar - avatar
1 Answer
+ 8
The arguments keyword can used to access the arguments passed to non-arrow functions, (meaning functions defined using the 'function' keyword, not those new ()=>{} ones). So, even though you did not specify that your function accepts arguments, when you passed 5 to it, arguments[0] can extract the value. 0 because arguments is an array-like object, not an array. external link: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Functions/arguments
15th Aug 2023, 2:23 AM
Bob_Li
Bob_Li - avatar