4 ms·
You're talking about two different things. In this case, you'd use... const user = Object.freeze({id: 1, status: 'active'}); But const is immaterial to t
by mywittyname 7y ago
You're talking about two different things. In this case, you'd use...
const user = Object.freeze({id: 1, status: 'active'});
But const is immaterial to this topic, as it only prevents you from being able to reassign user to some other value, i.e.,
user = 7;
While...
let user = Object.freeze({id: 1, status: 'active'});
user.status = 'disabled'; // throws an error.
Provides the behavior that you're seeking to guard against, regardless of let/var/const usage.
- wnevets 7y ago>You're talking about two different things. In this case, you'd use... No, I'm talking about the behavior of const.