HighDots Forums  

Creating an Object that extends Array functionality

Javascript JavaScript language (comp.lang.javascript)


Discuss Creating an Object that extends Array functionality in the Javascript forum.



Reply
 
Thread Tools Display Modes
  #41  
Old   
Dmitry A. Soshnikov
 
Posts: n/a

Default Re: Creating an Object that extends Array functionality - 10-28-2009 , 04:23 PM






On Oct 28, 9:10*pm, "Dmitry A. Soshnikov" <dmitry.soshni... (AT) gmail (DOT) com>
wrote:

Quote:
But for-in loops is also not so useful (it's slower) as for-length
loops as they analyze prototype chain (for all that [push], [pop] and
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
so on properties) and make the check on any iteration such as [if (!
property.isEnumerable()) continue;].

A little correction. Sure, prototype chain analysis can take place for
array and with [for-length] loops (but regardless for-length loop
itself - just via [[Get]]-method):

Array.prototype[0] = 10;

var a = [];
a[1] = 20;

for (var k = 0, length = a.length; k < length; k++) {
alert(a[k]); // 10, 20
}

But that's possible only again for sparse arrays, in normal case
(ordered indexes, 0-based started) this situation cannot be.

Reply With Quote
  #42  
Old   
Thomas 'PointedEars' Lahn
 
Posts: n/a

Default Re: Creating an Object that extends Array functionality - 10-28-2009 , 04:56 PM






kangax wrote:

Quote:
Thomas 'PointedEars' Lahn wrote:
kangax wrote:
Thomas 'PointedEars' Lahn wrote:
kangax wrote:
Are you sure you haven't missed anything?

"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"
So the thread has drifted a bit. Your approach touches ".prototype of
an
Array", too. That you are using `__proto__' to refer to said object
instead, does not change that.
Doesn't OP example make it clear what was meant by "touches"? If I
understood it right, the snippet with __proto__ setting doesn't "touch"
`Array.prototype`.

But the OP did not say "not use Array.prototype" to begin with; they
said:

Of course he did.
Not in what you quoted.

Quote:
You just seem to have missed it again.
Or maybe I understood the OP differently?

Quote:
Look at the second comment of OP's example.
You did not quote that; Richard did, and it is hardly relevant.

Quote:
var a = [2,4,6];
a.someAddedFunction(); // error - no Array .prototype extending
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
That is still not "Array.prototype". Look closer.

Quote:
Now look a bit further down:

var c = new SuperArray([2,4,6]);
[...]
c.someAddedFunction(); // calls function
^^^^^^^^^^^^^^

How more clear should it be?
"Array.prototype", but that would still be ambiguous (AISB).

Quote:
"not touch .prototype of an Array". And even if we assumed that
".prototype of an Array" is meant as "Array.prototype", there is still
ambiguity as to what that is supposed to mean:

a) a specific property accessor
b) the object referred to by the value that the accessed property stores

It stands to reason that "not touch .prototype of an Array" or "not touch
Array.prototype" means (b), because the OP does not want to add
(enumerable)
properties to that object (see for-in). And your suggestion of using
`[].__proto__' instead of `Array.prototype' in the source code does not
help with that because `[].__proto__ === Array.prototype' where
`__proto__' is

The fact that `[].__proto__` and `Array.prototype` reference same object
is irrelevant here.
It is not.

Quote:
The idea is to make sure `[]`'s [[Prototype]]
references another object (i.e. inject that object into a scope chain of
`[]`).
And thereby you overwrite the ".prototype of the Array" despite the OPs
requirement that it not be "touched".

Quote:
Changing `Array.prototype` would, obviously, change what
`Array.prototype` references, not what `[]`'s [[Prototype]] references.
This is the same in green. [psf 4.5]

Quote:
15.4.2.2 new Array(len)

The [[Prototype]] property of the newly constructed object is set to the
original Array prototype object, the one that is the initial value of
Array.prototype (section 15.4.3.1). [...]

11.1.4 Array Initialiser

[...]
The production ArrayLiteral : [ Elision_opt ] is evaluated as follows:

1. Create a new array as if by the expression new Array().

[...]
The production ArrayLiteral : [ ElementList ] is evaluated as follows:

1. Evaluate ElementList.
2. Return Result(1).

The production ArrayLiteral : [ ElementList , Elision_opt ] is evaluated
as follows:

1. Evaluate ElementList.
[...]

The production ElementList : Elision_opt AssignmentExpression is evaluated
as follows:

1. Create a new array as if by the expression new Array().
[...]

I still don't see your point here.
Read again. The OP very likely wants to avoid having an enumerable property
on the prototype object. Very likely they could not care less how the
prototype object is _not_ accessed.

Quote:
supported. In fact, replacing the prototype object like you did
decreases runtime efficiency; maybe negligibly, but IMHO needlessly.

You mean now that we have one more object in prototype chain? Sure it
does, but, as you said, this is very likely so negligible that there's
no need to worry about it.
One does if it does not satisfy the requirement of not modifying the
prototype to begin with. The was a purpose in that requirement that
you have ignored.


PointedEars
--
Use any version of Microsoft Frontpage to create your site.
(This won't prevent people from viewing your source, but no one
will want to steal it.)
-- from <http://www.vortex-webdesign.com/help/hidesource.htm> (404-comp.)

Reply With Quote
  #43  
Old   
Dmitry A. Soshnikov
 
Posts: n/a

Default Re: Creating an Object that extends Array functionality - 10-28-2009 , 05:34 PM



On Oct 28, 11:56*pm, Thomas 'PointedEars' Lahn <PointedE... (AT) web (DOT) de>
wrote:

Quote:
[...]
error - no Array .prototype extending
* * * * * * * * * * * * * * ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

That is still not "Array.prototype". *Look closer.

I hope you don't mean "there's a space before dot" in
"Array .prototype" vs. "Array.prototype"? If it's - i suggest you
to decrees you pathos

Quote:
[...]
How more clear should it be?

"Array.prototype"

ah, come on it's sort of joke or I missed something?


Quote:
[...]
* * The idea is to make sure `[]`'s [[Prototype]]
references another object (i.e. inject that object into a scope chain of
`[]`).

And thereby you overwrite the ".prototype of the Array" despite the OPs
requirement that it not be "touched".

Excuse me, do you really don't understand what OP have asked? Or it's
again kind of privileged humor that I can't get in?

Quote:
Changing `Array.prototype` would, obviously, change what
`Array.prototype` references, not what `[]`'s [[Prototype]] references.

This is the same in green. [psf 4.5]

Changing [].[[Prototype]] as modifying - sure will affect on original
Array.prototype, but here the talk about changing in meaning of full
changing, where object on which Array.prototype points will not be
touched.

Quote:
Read again. *The OP very likely wants to avoid having an enumerable property
on the prototype object. *Very likely they could not care less how the
prototype object is _not_ accessed.

OP just wants do not touch object on with points Array.prototype
('cause someone whom he believes as authority recommended that) - as
he afraid of for-in loops for ordinary arrays. He just want to create
own extension and kangax and Richard give such examples, though, OP
still should "afraid" of for-in loops for that extended object, but
not for the ordinary arrays => goal is reached. What exactly you don't
understand?

Reply With Quote
  #44  
Old   
kangax
 
Posts: n/a

Default Re: Creating an Object that extends Array functionality - 10-29-2009 , 12:30 AM



Thomas 'PointedEars' Lahn wrote:
Quote:
kangax wrote:

Thomas 'PointedEars' Lahn wrote:
kangax wrote:
Thomas 'PointedEars' Lahn wrote:
kangax wrote:
Are you sure you haven't missed anything?

"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"
So the thread has drifted a bit. Your approach touches ".prototype of
an
Array", too. That you are using `__proto__' to refer to said object
instead, does not change that.
Doesn't OP example make it clear what was meant by "touches"? If I
understood it right, the snippet with __proto__ setting doesn't "touch"
`Array.prototype`.
But the OP did not say "not use Array.prototype" to begin with; they
said:
Of course he did.

Not in what you quoted.

You just seem to have missed it again.

Or maybe I understood the OP differently?
Ok.

Quote:
Look at the second comment of OP's example.

You did not quote that; Richard did, and it is hardly relevant.
Should I quote specific lines every time? Are you not able to understand
the issue as a whole? Everyone seemed to have understood OP identically
(more or less), except you.

Think outside the box

Quote:
var a = [2,4,6];
a.someAddedFunction(); // error - no Array .prototype extending
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

That is still not "Array.prototype". Look closer.
You're joking, right?

Quote:
Now look a bit further down:

var c = new SuperArray([2,4,6]);
[...]
c.someAddedFunction(); // calls function
^^^^^^^^^^^^^^

How more clear should it be?

"Array.prototype", but that would still be ambiguous (AISB).
Oh, come on.

[...]

Quote:
The idea is to make sure `[]`'s [[Prototype]]
references another object (i.e. inject that object into a scope chain of
`[]`).

And thereby you overwrite the ".prototype of the Array" despite the OPs
requirement that it not be "touched".
Overwrite it? Where?

Let's look at a snippet again:

var augment = (function(){
var mixin = {
last: function() {
return this[this.length-1];
},
__proto__: Array.prototype
};
return function(object) {
object.__proto__ = mixin;
return object;
};
})();

var arr = augment([1,2,3]);

Please show me at which point is `Array.prototype` "overwritten" (or, to
be specific — at which point does `Array.prototype` reference object
different than the one it originally references and/or at which point do
the properties of that object get modified)?

Quote:
Changing `Array.prototype` would, obviously, change what
`Array.prototype` references, not what `[]`'s [[Prototype]] references.

This is the same in green. [psf 4.5]

| 15.4.2.2 new Array(len)
|
| The [[Prototype]] property of the newly constructed object is set to the
| original Array prototype object, the one that is the initial value of
| Array.prototype (section 15.4.3.1). [...]

| 11.1.4 Array Initialiser
|
| [...]
| The production ArrayLiteral : [ Elision_opt ] is evaluated as follows:
|
| 1. Create a new array as if by the expression new Array().
|
| [...]
| The production ArrayLiteral : [ ElementList ] is evaluated as follows:
|
| 1. Evaluate ElementList.
| 2. Return Result(1).
|
| The production ArrayLiteral : [ ElementList , Elision_opt ] is evaluated
| as follows:
|
| 1. Evaluate ElementList.
| [...]
|
| The production ElementList : Elision_opt AssignmentExpression is evaluated
| as follows:
|
| 1. Create a new array as if by the expression new Array().
| [...]

I still don't see your point here.

Read again. The OP very likely wants to avoid having an enumerable property
on the prototype object. Very likely they could not care less how the
prototype object is _not_ accessed.
Of course. In fact, that enumerable property is never added to
`Array.prototype`, just as OP asked.

What is the problem here?

[...]

--
kangax

Reply With Quote
  #45  
Old   
Jorge
 
Posts: n/a

Default Re: Creating an Object that extends Array functionality - 10-29-2009 , 04:58 AM



On Oct 29, 5:30*am, kangax <kan... (AT) gmail (DOT) com> wrote:
Quote:
Thomas 'PointedEars' Lahn wrote:
kangax wrote:

Thomas 'PointedEars' Lahn wrote:
kangax wrote:
Thomas 'PointedEars' Lahn wrote:
kangax wrote:
Are you sure you haven't missed anything?

"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"
So the thread has drifted a bit. *Your approach touches ".prototype of
an
Array", too. *That you are using `__proto__' to refer to said object
instead, does not change that.
Doesn't OP example make it clear what was meant by "touches"? If I
understood it right, the snippet with __proto__ setting doesn't "touch"
`Array.prototype`.
But the OP did not say "not use Array.prototype" to begin with; they
said:
Of course he did.

Not in what you quoted.

You just seem to have missed it again.

Or maybe I understood the OP differently?

Ok.



Look at the second comment of OP's example.

You did not quote that; Richard did, and it is hardly relevant.

Should I quote specific lines every time? Are you not able to understand
the issue as a whole? Everyone seemed to have understood OP identically
(more or less), except you.

Think outside the box



var a = [2,4,6];
a.someAddedFunction(); *// error - no Array .prototype extending
* * * * * * * * * * * * * * ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

That is still not "Array.prototype". *Look closer.

You're joking, right?



Now look a bit further down:

var c = new SuperArray([2,4,6]);
[...]
c.someAddedFunction(); // calls function
* * * * * * * * * * * * * *^^^^^^^^^^^^^^

How more clear should it be?

"Array.prototype", but that would still be ambiguous (AISB).

Oh, come on.

[...]

* * The idea is to make sure `[]`'s [[Prototype]]
references another object (i.e. inject that object into a scope chain of
`[]`).

And thereby you overwrite the ".prototype of the Array" despite the OPs
requirement that it not be "touched".

Overwrite it? Where?

Let's look at a snippet again:

var augment = (function(){
* *var mixin = {
* * *last: function() {
* * * *return this[this.length-1];
* * *},
* * *__proto__: Array.prototype
* *};
* *return function(object) {
* * *object.__proto__ = mixin;
* * *return object;
* *};

})();

var arr = augment([1,2,3]);

Please show me at which point is `Array.prototype` "overwritten" (or, to
be specific — at which point does `Array.prototype` reference object
different than the one it originally references and/or at which point do
the properties of that object get modified)?







Changing `Array.prototype` would, obviously, change what
`Array.prototype` references, not what `[]`'s [[Prototype]] references..

This is the same in green. [psf 4.5]

| 15.4.2.2 new Array(len)
|
| The [[Prototype]] property of the newly constructed object is set to the
| original Array prototype object, the one that is the initial value of
| Array.prototype (section 15.4.3.1). [...]

| 11.1.4 Array Initialiser
|
| [...]
| The production ArrayLiteral : [ Elision_opt ] is evaluated as follows:
|
| 1. Create a new array as if by the expression new Array().
|
| [...]
| The production ArrayLiteral : [ ElementList ] is evaluated as follows:
|
| 1. Evaluate ElementList.
| 2. Return Result(1).
|
| The production ArrayLiteral : [ ElementList , Elision_opt ] is evaluated
| as follows:
|
| 1. Evaluate ElementList.
| [...]
|
| The production ElementList : Elision_opt AssignmentExpression is evaluated
| as follows:
|
| 1. Create a new array as if by the expression new Array().
| [...]

I still don't see your point here.
(...)
I bet he's trying hard not to say that it's the instance's
original .__proto__ what should go inside __proto__ in the 'mixin',
instead of assuming that it was === Array.prototype.
--
Jorge.

Reply With Quote
  #46  
Old   
Thomas 'PointedEars' Lahn
 
Posts: n/a

Default Re: Creating an Object that extends Array functionality - 10-29-2009 , 06:48 AM



kangax wrote:

Quote:
Thomas 'PointedEars' Lahn wrote:
kangax wrote:
Thomas 'PointedEars' Lahn wrote:
kangax wrote:
Thomas 'PointedEars' Lahn wrote:
kangax wrote:
Are you sure you haven't missed anything?

"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"
So the thread has drifted a bit. Your approach touches ".prototype
of an
Array", too. That you are using `__proto__' to refer to said object
instead, does not change that.
Doesn't OP example make it clear what was meant by "touches"? If I
understood it right, the snippet with __proto__ setting doesn't
"touch" `Array.prototype`.
But the OP did not say "not use Array.prototype" to begin with; they
said:
Of course he did.

Not in what you quoted.

You just seem to have missed it again.

Or maybe I understood the OP differently?

Ok.


Look at the second comment of OP's example.

You did not quote that; Richard did, and it is hardly relevant.

Should I quote specific lines every time? Are you not able to understand
the issue as a whole? Everyone seemed to have understood OP identically
(more or less), except you.
They did not. In any case:

The fact that an opinion has been widely held is no evidence whatever that
it is not utterly absurd; indeed in view of the silliness of the majority
of mankind, a widespread belief is more likely to be foolish than
sensible.
-- Bertrand Russell (1872-1970 CE)

Quote:
Think outside the box
The box that you do not want to see is that "not touch the .prototype of an
Array" was very likely a figure of speech to say "not augment the prototype
object of an Array instance."

Quote:
var a = [2,4,6];
a.someAddedFunction(); // error - no Array .prototype extending
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

That is still not "Array.prototype". Look closer.

You're joking, right?
I do not.

Quote:
Now look a bit further down:

var c = new SuperArray([2,4,6]);
[...]
c.someAddedFunction(); // calls function
^^^^^^^^^^^^^^

How more clear should it be?

"Array.prototype", but that would still be ambiguous (AISB).

Oh, come on.
Is that supposed to be an argument?

Quote:
The idea is to make sure `[]`'s [[Prototype]]
references another object (i.e. inject that object into a scope chain of
`[]`).

And thereby you overwrite the ".prototype of the Array" despite the OPs
requirement that it not be "touched".

Overwrite it? Where?

Let's look at a snippet again:

var augment = (function(){
var mixin = {
last: function() {
return this[this.length-1];
},
__proto__: Array.prototype
};
return function(object) {
object.__proto__ = mixin;
return object;
};
})();

var arr = augment([1,2,3]);
That is _not_ the code in question. The code in question has been commented
on first in <news:6582835.2qOKlZ2vcF (AT) PointedEars (DOT) de>, and posted by you in
<news:uq6dnerJAYtGunrXnZ2dnUVZ_u6dnZ2d (AT) giganews (DOT) com>.

In any case, both approaches fail to address the requirement of "not
touch[ing] the .prototype of an Array". The resulting Array instance will
inherit enumerable properties that show up in for-in iteration.


PointedEars
--
realism: HTML 4.01 Strict
evangelism: XHTML 1.0 Strict
madness: XHTML 1.1 as application/xhtml+xml
-- Bjoern Hoehrmann

Reply With Quote
  #47  
Old   
Dmitry A. Soshnikov
 
Posts: n/a

Default Re: Creating an Object that extends Array functionality - 10-29-2009 , 07:14 AM



On Oct 29, 1:48*pm, Thomas 'PointedEars' Lahn <PointedE... (AT) web (DOT) de>
wrote:
Quote:
kangax wrote:
Thomas 'PointedEars' Lahn wrote:
kangax wrote:
Thomas 'PointedEars' Lahn wrote:
kangax wrote:
Thomas 'PointedEars' Lahn wrote:
kangax wrote:
Are you sure you haven't missed anything?

"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"
So the thread has drifted a bit. *Your approach touches ".prototype
of an
Array", too. *That you are using `__proto__' to refer to said object
instead, does not change that.
Doesn't OP example make it clear what was meant by "touches"? If I
understood it right, the snippet with __proto__ setting doesn't
"touch" `Array.prototype`.
But the OP did not say "not use Array.prototype" to begin with; they
said:
Of course he did.

Not in what you quoted.

You just seem to have missed it again.

Or maybe I understood the OP differently?

Ok.

Look at the second comment of OP's example.

You did not quote that; Richard did, and it is hardly relevant.

Should I quote specific lines every time? Are you not able to understand
the issue as a whole? Everyone seemed to have understood OP identically
(more or less), except you.

They did not. *In any case:

* The fact that an opinion has been widely held is no evidence whateverthat
* it is not utterly absurd; indeed in view of the silliness of the majority
* of mankind, a widespread belief is more likely to be foolish than
* sensible.
* * -- Bertrand Russell (1872-1970 CE)

Man, sorry, but you're just collection of "authority" cites Do you
have your own opinion? I mean beside your shor "No.", "The did not.",
"No they are not" and so on - pathos phrases of those who belive
himself higher that other. Decrease your pathos, I repeat, it really
will be better


Quote:
[...]
You're joking, right?

I do not.

One more time "You do not". "No.", "They do not.", "Everybody's
lie.", "No."

Quote:
Now look a bit further down:

var c = new SuperArray([2,4,6]);
[...]
c.someAddedFunction(); // calls function
* * * * * * * * * * * * * *^^^^^^^^^^^^^^

How more clear should it be?

"Array.prototype", but that would still be ambiguous (AISB).

Oh, come on.

Is that supposed to be an argument?

What argument do you expect else in case of your troll-like style
speaking (I mean concrete this one thread)?


Quote:
[...]
In any case, both approaches fail to address the requirement of "not
touch[ing] the .prototype of an Array". *The resulting Array instance will
inherit enumerable properties that show up in for-in iteration.

You still continue to sing your song, just because you can't say
(yeah, I understand - it's hard, when you believe yourself higher than
other ) - "sorry, guys, I did't understand it correctly", you still
continue talking about stupid "the .prototype of an Array" ===
"[[Prototype]] of []" without listening kangax.

k, one more time: You didn't understand it correctly. OP has meant: "I
don't want to touch the object on which points Array.prototype as I
don't wanna break down [for-in] loops for ordinary arrays. But I don't
care what will be in [for-in] loops with own extended object". Is it
so hard to understand?

Reply With Quote
  #48  
Old   
Thomas 'PointedEars' Lahn
 
Posts: n/a

Default Re: Creating an Object that extends Array functionality - 10-29-2009 , 07:27 AM



Dmitry A. Soshnikov wrote:

Quote:
Thomas 'PointedEars' Lahn wrote:
kangax wrote:
Should I quote specific lines every time? Are you not able to
understand the issue as a whole? Everyone seemed to have understood OP
identically (more or less), except you.

They did not. In any case:

The fact that an opinion has been widely held is no evidence whatever
that it is not utterly absurd; indeed in view of the silliness of the
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
majority of mankind, a widespread belief is more likely to be foolish
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^
than sensible.
^^^^^^^^^^^^^^
-- Bertrand Russell (1872-1970 CE)

[...]
[...]
In any case, both approaches fail to address the requirement of "not
touch[ing] the .prototype of an Array". The resulting Array instance
will inherit enumerable properties that show up in for-in iteration.

You still continue to sing your song, just because you can't say
(yeah, I understand - it's hard, when you believe yourself higher than
other ) - "sorry, guys, I did't understand it correctly", you still
continue talking about stupid "the .prototype of an Array" ===
"[[Prototype]] of []" [...]
q.e.d.


PointedEars
--
var bugRiddenCrashPronePieceOfJunk = (
navigator.userAgent.indexOf('MSIE 5') != -1
&& navigator.userAgent.indexOf('Mac') != -1
) // Plone, register_function.js:16

Reply With Quote
  #49  
Old   
Dmitry A. Soshnikov
 
Posts: n/a

Default Re: Creating an Object that extends Array functionality - 10-29-2009 , 07:35 AM



On Oct 29, 2:27*pm, Thomas 'PointedEars' Lahn <PointedE... (AT) web (DOT) de>
wrote:
Quote:
Dmitry A. Soshnikov wrote:
Thomas 'PointedEars' Lahn wrote:
kangax wrote:
Should I quote specific lines every time? Are you not able to
understand the issue as a whole? Everyone seemed to have understood OP
identically (more or less), except you.

They did not. *In any case:

The fact that an opinion has been widely held is no evidence whatever
that it is not utterly absurd; indeed in view of the silliness of the

* * * * * * * * * * * * * * * * * ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^>> majority of mankind, a widespread belief is more likely to be foolish

* *^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^

than sensible.
* *^^^^^^^^^^^^^^
-- Bertrand Russell (1872-1970 CE)

[...]
[...]
In any case, both approaches fail to address the requirement of "not
touch[ing] the .prototype of an Array". *The resulting Array instance
will inherit enumerable properties that show up in for-in iteration.

You still continue to sing your song, just because you can't say
(yeah, I understand - it's hard, when you believe yourself higher than
other ) - "sorry, guys, I did't understand it correctly", you still
continue talking about stupid "the .prototype of an Array" ===
"[[Prototype]] of []" [...]

q.e.d.

PointedEars
--
var bugRiddenCrashPronePieceOfJunk = (
* * navigator.userAgent.indexOf('MSIE 5') != -1
* * && navigator.userAgent.indexOf('Mac') != -1
) *// Plone, register_function.js:16
don't be worry, you already lost

Again advise to you (you should sure ignore it ) - try to discuss
with more scientific approach and without thinking that you're higher
than other (if you want the objective meaning - you're now just a bit
deeper in ES than casual programmer, so don't lie to yourself when
talking with other from the top ).

And yep - the talk is over with you.

Reply With Quote
  #50  
Old   
wilq
 
Posts: n/a

Default Re: Creating an Object that extends Array functionality - 11-05-2009 , 06:02 AM



Thanks all of you of interesting answers. It seems that this is
impossible to do in all browsers. I really like a Kangax solution. But
unfortunatelly it does not work on IE (because of __proto__)
Hopefully future JavaScript solutions will allow this kind of problem
to be solved. Cheers,

wilq32

Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.