Email or username:

Password:

Forgot your password?
Top-level
Hazel :pleadingcat:

@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: developer.mozilla.org/en-US/do

2 comments
Hazel :pleadingcat:

@lily
const obj = {}
obj.whatever = “i can do this”
obj = { butICannot: “do this” }

const arr = []
arr.push(“this is fine!”)
arr = [“but this will throw.”]

it is Just the = on the variable itself, none of its fields or anything is constant

Hazel :pleadingcat:

@lily what i find more weird honestly is how strict strings and numbers are. cause- why doesnt this work? strings are arrays of characters why are they more constant than normal arrays?

Go Up