Cofounded Host Collective (DiscountASP.net). Cofounded Player Axis (Social Gaming). Computer Scientist and Technology Evangelist with 20+ years of experience with JavaScript!
that is kind of why I mentioned '(just a note, const doesn't make object immutable, you have to freeze)' was to distinguish between const and immutable.
If you want a primitive value to be immutable, const is enough. If you want an object to be immutable, you have to freeze it as well.
So if we can assume groceries is immutable (which is should be).
that is kind of why I mentioned '(just a note, const doesn't make object immutable, you have to freeze)' was to distinguish between const and immutable.
If you want a primitive value to be immutable,
const
is enough. If you want an object to be immutable, you have to freeze it as well.So if we can assume
groceries
is immutable (which is should be).Then your groceries will truly be immutable
Sorry. Misunderstood as the freeze wasn't mentioned in the previous code. Thanks for clearing it up! :)