@h
> const array
> modifies it
wtf javascript
yea ik it's probably shallow immutably like zig..
but that implies that the length is stored behind a pointer??
Top-level
8 comments
@h @lily yeah the indices are all treated as strings (but optimised internally). by the spec arrays are "exotic objects", which means their impl can do weird things ( also fun fact most array methods dont actually require an array, so you can do |
@lily arrays and objects do this in js yes. what const means is you cannot change it with the = statement. you can push to an array, pop elements off, you can access properties of objects and methods on them and change all of them- but you cant go and do
obj = {something: “else”}
. practically its constant for numbers and strings.However- there is a way to have it constant at a deeper level: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/freeze