W
wilq
Hello Usenet,
I got an interesting question and maybe some of you might have idea or
at least want to have some riddle to solve... whatever. I would like
to create own Object that would behave similar to Array Object, but
would have defined some methods that are not in current Array
implementation. It need to not touch .prototype of an Array, so it
should work like this:
var a = [2,4,6];
a.someAddedFunction(); // error - no Array .prototype extending
var c = new SuperArray([2,4,6]);
for (var i=0,l=c.length;i<l;i++)
{
alert(c); // alerts 2, then 4, then 6
}
c.someAddedFunction(); // calls function
Have you got any idea how to do that? Is this possible at all? Thanks
for any answers here.
I got an interesting question and maybe some of you might have idea or
at least want to have some riddle to solve... whatever. I would like
to create own Object that would behave similar to Array Object, but
would have defined some methods that are not in current Array
implementation. It need to not touch .prototype of an Array, so it
should work like this:
var a = [2,4,6];
a.someAddedFunction(); // error - no Array .prototype extending
var c = new SuperArray([2,4,6]);
for (var i=0,l=c.length;i<l;i++)
{
alert(c); // alerts 2, then 4, then 6
}
c.someAddedFunction(); // calls function
Have you got any idea how to do that? Is this possible at all? Thanks
for any answers here.