+ 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
1 ответ
+ 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