When you use `Object.create(Object.getPrototypeOf([]))` the resulting object has the same prototype as an array; but it is not a true array because the object was not produced by the Array() constructor.
I believe that the JSON serialization in this case is technically correct - even though it does not produce the result that Francisco would like.
Maybe you could modify your Enumerable mixin to skip adding methods to objects that already implement a method with the same name? Replacing native methods is likely to cause lots of weird issues.
On Apr 20, 2010 9:40 AM, "francisco treacy" <francisc...@gmail.com> wrote:
node> var a = [ {id: 1}, {id: 2}, {id: 3} ].filter(function(n) {
return n.id !== 2 })
[ { id: 1 }, { id: 3 } ]
node> JSON.stringify(a)
'[{"id":1},{"id":3}]'
This is all I want.
When I do *exactly the same* in an express webapp, I get
{"0":{"id":1},"1":{"id":3},"length":2}
No idea if the problem lies in node or v8!
Thanks =)
2010/4/20 vision media [ Tj Holowaychuk ] <t...@vision-media.ca>:
> In the repl I get an array of ob...
--
You received this message because you are subscribed to the Google Groups "Express" group.
To post t...
Well, if a JSON implentation used instanceof to check for an array it would not be in compliance with the JSON spec. It is not an object's prototype that makes it an array. It is the Array() constructor that does that.
To generalize on that point, you could also point to examples of user defined objects where an object cannot be treated as the same type as another object with the same prototype but that was created by a different constructors. Constructors populate required properties and define priviliged methods and so forth.
On Apr 20, 2010 10:07 AM, "vision media [ Tj Holowaychuk ]" <t...@vision-media.ca> wrote:
For sure, I understand that, but you would think they could just do an "instanceof Array" check.
On Tue, Apr 20, 2010 at 9:55 AM, Jesse Hallett <hall...@gmail.com> wrote:
>
--
> When you use `Object.create(Object.getPrototypeOf([]))` the resulting object has the same protot...
> You received this message because you are subscribed to the Google Groups "Express" group.
> To post to this group, send email to expre...@googlegroups.com.
> To unsubscribe from this group...
--
Tj Holowaychuk
Vision Media
President & Creative Lead
--You received this message because you are subscribed to the Google Groups "Express" group.
To post to this group, send email to expre...@googlegroups.com.
To unsubscribe from this group, se...