[Javascript] custom extension of Array object
james
james at southspace.org
Thu Apr 14 16:52:03 CDT 2005
At 19:22 14/04/2005 +0200, you wrote:
>Like this?
>
> function CustomArray(){
> }
> CustomArray.prototype=new Array;
>
> var
> ca=new CustomArray;
> ca.push('test');
> ca.push('test');
> ca.push('test');
> alert(ca); // => test,test,test
aha! what I was doing was this
function CustomArray() {
this.prototype = new Array();
.....
}
which doesn't work!
is there a difference between setting the prototype of the object and
setting the prototype of the constructor function??.
sorry if this is annoying newbie stuff, I am from PHP/Lingo background, I
love this dynamic language, but it can be very confusing!
James
More information about the Javascript
mailing list