I was reading this on MDN - https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Functions/Arrow_functions
In a section titled "No binding of arguments" I saw the following and tried it on the browser console. Works.
No binding of arguments
Arrow functions do not have their own arguments object. Thus, in this example, > arguments is simply a reference to the the arguments of the enclosing scope:
When I tried to debug the arrow function, the value of arguments is different and unexpected. Is this a bug in DevTools or am I overlooking something?
In the example below, arguments.length
printed in the console is 1. (The value being 1)
However, when execution stops at a breakpoint, arguments.length
is 4. (The values being 1, 6, 7, 8)
(function() {
var obj = {
fn: function(a) {
var f = v=> {
debugger;
console.log("Arguments length " + arguments.length);
};
return f(a, 6, 7, 8);
}
};
obj.fn(1);
}
)();
jsFiddle here - https://jsfiddle.net/3Lb640aq/