Non-extensibility of Typed Arrays

Allen Wirfs-Brock allen at wirfs-brock.com
Tue Aug 27 09:56:03 PDT 2013


On Aug 27, 2013, at 9:43 AM, Allen Wirfs-Brock wrote:

> 
> On Aug 27, 2013, at 9:26 AM, Domenic Denicola wrote:
> 
>> I am not aware of all the nuances of the discussion, but as a developer I would find the behavior for numeric expandos confusing. For a typed array of length 1024, setting `ta[1023]` would do something completely different from setting `ta[1024]`. Unlike normal arrays, setting `ta[1024]` would not change `ta.length`, and presumably `ta[1024]` would not be exposed by the various iteration facilities.
>> 
>> I would much rather received a loud error (in strict mode), which will either alert me to my code being weird, or possibly to my code committing an off-by-one error.
> 
> Integer numeric expandos on TypedArrays (eg, outside the range 0..length-1) are disallowed by the ES6 spec. in a manner that is independent of the[[Extensible]] internal property.  The discussion at the meeting was about non-numeric expandos such as 'foo'.

To clarify, out of range [[Get]] returns undefined and out of range [[Put]] is either a noop or a throw depending upon the strictness of code doing the [[Put]] (ie, normal [[Put]] strict behavior)





> 
> Allen
> 
> 
> _______________________________________________
> es-discuss mailing list
> es-discuss at mozilla.org
> https://mail.mozilla.org/listinfo/es-discuss
> 



More information about the es-discuss mailing list