Reputation:
Is this correct? Is this new?
I mean the implicit arguments that each function has btw.
I noticed that my code is failing when I use arguments in strict mode, if I remove strict mode not problem ... is this new or has it always been this way ?
console.log('foo.js running');
(function() {
// 'use strict';
// unexpected arguments in strict mode ...
and here is where I use it:
_.extend = function(obj) {
_.each(Array.prototype.slice.call(arguments, 1), function (object) {
_.each(object, function(val, key){
obj[key] = val;
})
});
return obj;
}
Upvotes: 0
Views: 61
Reputation: 1074475
No, strict mode does not prevent use of arguments
. It does change it slightly: The arguments
object is no longer tied to the named parameters, so:
function loose(a) {
console.log(a);
arguments[0] = "bar"; // Changes `a`
console.log(a);
}
function strict(a) {
"use strict";
console.log(a);
arguments[0] = "bar"; // Does not change `a`
console.log(a);
}
loose("foo");
strict("foo");
Upvotes: 1