O
optimistx
Some people recommend not to add methods and properties to objects like
Array. The reason being that the names of those might collide with other
programs on the same page made by others.
The exception to this seems to be methods, which are included in the newer
versions of javascript: they might be coded if not existing already.
How would I then extend an Array? Define my own MyArray in my own namespace,
and use Array as a prototype or ancestor for it? Then use it like
myarray1 = new MyArray (...);
myarray2 = new MyArray (...);
myarray1.nicenewmethod();
or something else: simple, elegant, educational, intuitive, robust,
efficient, memoryefficient,
programmerfriendly, socially polished, expertlike, artistic, beautiful, ...
?
Example of such a code?
Array. The reason being that the names of those might collide with other
programs on the same page made by others.
The exception to this seems to be methods, which are included in the newer
versions of javascript: they might be coded if not existing already.
How would I then extend an Array? Define my own MyArray in my own namespace,
and use Array as a prototype or ancestor for it? Then use it like
myarray1 = new MyArray (...);
myarray2 = new MyArray (...);
myarray1.nicenewmethod();
or something else: simple, elegant, educational, intuitive, robust,
efficient, memoryefficient,
programmerfriendly, socially polished, expertlike, artistic, beautiful, ...
?
Example of such a code?