From: es-discuss [mailto:es-discuss-boun...@mozilla.org] On Behalf Of Tom Van 
Cutsem

> Is the `length` invariant really the dominant meaning JS developers attribute 
> to Array.isArray? I think to most developers Array.isArray(obj) returning 
> true means that it's safe to call the array utilities (map, forEach, ...) on 
> obj, not so much that obj.length is special.

This is really interesting. It does argue for some kind of redefinition of 
Array.isArray to return "is this an instance of some %ArrayPrototype% in some 
realm?" That is very close to "does the object have an @@isConcatSpreadable" 
property, the main difference being that you can "fake" the latter via 
`myObj[Symbol.isConcatSpreadable] = true` while still not inheriting from any 
%ArrayPrototype%.

---

To me the most interesting question is how to create objects that get 
JSON-stringified as [], not {}. Some sort of symbol-based mechanism makes sense 
for that, IMO...

_______________________________________________
es-discuss mailing list
es-discuss@mozilla.org
https://mail.mozilla.org/listinfo/es-discuss

Reply via email to