A past puzzle — fully playable. 4 attempts, hints on wrong guesses.
stdle-121.js
1constlist=[10,20];
2functionf(){returnlist.map(function(x){
3returnarguments.length;
4});}
5console.log(f().join(","));
Scope
Answer & explanation
Console output
3,3
Why
Each regular function has its own arguments object reflecting how it was called, and Array.prototype.map always invokes its callback with three arguments: the element, the index, and the array. So inside the callback arguments.length is 3 for every element, not the number of parameters written. This is a frequent surprise when a callback only declares one parameter but inspects arguments.