As a JavaScript developer, it’s possible that you might have used strict mode at one point or the other in your code and if you haven’t, well, you might someday. Strict mode can be helpful when trying to debug your app because it brings up errors that you normally wouldn’t expect in sloppy mode (more on that later), the opposite of strict mode, so let’s get to it.
First introduced in the ECMAScript version 5, strict mode is a way of ensuring our code doesn’t have any loose ends. …
Ever wondered how to prevent your code from mutating object properties whose values should never change?
I know what you’re probably thinking, why not just use a const keyword to declare the object? well, doing it that way would only prevent the variable itself from being mutated and not the object properties, for example:
One way we could achieve this is to use the Object.freeze()
method, but that locks down the entire object and in some cases we might not want that to happen, Object.freeze()
…
Front End Developer