I have a function like below. When I create a new object of the function like this:
var newArray = new ArrayCollection ();
In the newArray I want to access the function property and class like this:
var first= newArray[0]
Instead of:
var first = newArray.Collections[0]
And:
newArray.add("a");
How to I modify the function to do this?
ArrayCollection = function ()
{
this.Collections = new Array();
this.add = function ( value )
{
....
};
this.remove = function ( value )
{
....
};
this.insert = function ( indx, value )
{
....
};
this.clear = function ()
{ ...
}
}
return [firstObject, secondObject];. Answer to the rest of the post (it seems to be pretty unrelated to title): make your collection class useArrayas prototype, or alter Array's prototype as Emissary suggests. (By the way, please consider accepting some answers people provided to your other questions.)