DEV Community

Discussion on: Constants are not really constants

sadick profile image

I agree that changing the behaviour makes sense. But what if we wanted to maintain the behaviour, what name could we give to that behaviour. cannot reassign but can modify.

Thread Thread
aminnairi profile image
Amin Author

We could follow the path taken by Elm and their awesome error messages like:

I saw you used a constant here:

const fruits = [...];

It seems like you tried to update one of its member:

fruits[0] = ...

I think that you might wanna use Object.freeze to prevent causing side effects

const fruits = Object.freeze([...]);