Inheriting from Array not working as expected (JScript)
SuperArray.prototype = new Array();
SuperArray.prototype.constructor = SuperArray;
function SuperArray()
{
if(arguments.length > 0)
{
if(Object.prototype.toString.call(arguments[0]) == '[object Array]' && arguments.length == 1)
{
this.parseArray(arguments[0]);
}
else
{
for(var j = 0; j < arguments.length; j++)
{
this.push(arguments
}
}
}
...
}
When the argument 'array' is pushed into the array object SuperArray extends, it does not increase the length of the array object (length is always 0). Every call to 'push()' simply overwrites the last variable (you get [0] = first arg, [0] = second arg... [0] = nth arg), and all the while, length remains 0 (even though it should really be at least 1). When I inspect an instance of SuperArray(), it shows none of the methods declared within its constructor.
What do I need to do to get this to work (I would prefer not to have a highly inelegant solution like simply including a normal array instance as a member of SuperArray, and modifying that)?