javascript - Can arguments be overwritten? -
according mozilla document, arguments
can set:
arguments[1] = 'new value';
but jshint
refuses accept that. can arguments set or not?
this have now:
handlebars.registerhelper('proppartial', function(property, options) { var name = ember.handlebars.get(this, property); // have because arguments[0] = name; not work, contrary stated here: // https://developer.mozilla.org/en-us/docs/web/javascript/reference/functions_and_function_scope/arguments var args = [], i, l; args.push(name); (i = 1, l = arguments.length; < l; i++) { args.push(arguments[i]); } return ember.handlebars.helpers.partial.apply(this, args); });
update, reference
thanks @tjcrowder, working code, fooling jshint
:
handlebars.registerhelper('proppartial', function(property, options) { var name = ember.handlebars.get(this, property); var args = arguments; args[0] = name; return ember.handlebars.helpers.partial.apply(this, args); });
yes, can. there lots of things can in javascript jslint has issues with.
i don't suggest it, can it.
if really, want , pass jslint
, can fool it:
var = arguments; a[1] = 'new value';
note link between arguments
, named arguments in function live in loose mode. e.g.:
function foo(a, b) { arguments[1] = "x"; // line changes `b` console.log("a = " + a); console.log("b = " + b); } foo(1, 2);
outputs
a = 1 b = x
in strict mode, though, don't remain linked:
function foo(a, b) { "use strict"; arguments[1] = "x"; // line *not* change `b` console.log("a = " + a); console.log("b = " + b); } foo(1, 2);
outputs
a = 1 b = 2
Comments
Post a Comment