You can set individual elements of a argumentsfunction property (that Mozilla calls an array-like property), however Mozilla messages cannot add elements to this property in SpiderMonkey 1.5, although this is fixed in 1.6 (link to SpiderMonkey here ... https: //developer.mozilla.org/en/JavaScript/Reference/Functions_and_function_scope/arguments ).
This is a useful property, chaining constructors from subclasses, creating a list of arguments to jump to a function (e.g. myclassmethod.apply(this, arguments)), etc.
However, I found that V8 will not extend the length in the same way as Mozilla reports on SpiderMonkey 1.5. (Not sure what the status is with other JavaScript, Opera, Rhino, etc. mechanisms).
Is this an ECMA feature? Was Mozilla wrong when considering this error, or does V8 have an error to fix?
[Update] I found that with V8 you can assign a property arguments.length, and therefore argumentscan be effectively extended (or set to whatever length you need). However, JSLint complains that this is a bad assignment.
[Refresh] Some test codes, if someone wants to try this in Opera, FF, etc., create an instance of a subclass calling the constructor with one argument, adding an element to argumentsin the constructor of the subclass and calling the superclass constructor, the superclass should report two arguments :
function MyClass() {
if (arguments.length) {
console.log("arguments.length === " + arguments.length);
console.log("arguments[0] === " + arguments[0]);
console.log("arguments[1] === " + arguments[1]);
}
}
function MySubClass() {
console.log(arguments.length);
arguments[1] = 2;
MyClass.apply(this, arguments);
}
MySubClass.prototype = new MyClass();
new MySubClass(1);
[Update] JSLint really complains when you perform any assignment argumentsin appearance (for example, arguments[0] = "foo"). Therefore, perhaps JSLint can also do here.