Hacker News new | past | comments | ask | show | jobs | submit login

Any behavior that is not defined in the spec[0] is, by definition, an implementation detail. Relying on undefined behavior is a recipe for bugs. If you need an immutable array, and the spec doesn't require the returned array to be immutable, you should create one yourself.

[0] https://tc39.es/ecma262/multipage/indexed-collections.html#s...




You are reading the wrong spec. That is `Array#slice`, not `TypedArray#slice`.

Correct spec: https://tc39.es/ecma262/multipage/indexed-collections.html#s...

Steps 14.g.i to 14.g.ix detail the transfer of data from the original TypedArray (O) to the new TypedArray (A). It involves reading values from the original and writing them to the new array's buffer, effectively duplicating the data segment. The process ensures both arrays are distinct with separate memory spaces.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: