What ‘use strict’ means for in JavaScript

“strict mode”;

It’s a ECMAScript 5 feature that prevents certain actions from being taken and throws more exceptions in a JavaScript code.
The strict mode is necessary if you have a complex code to write. It introduces better error-checking, If you have a calculating algorithm.
Without this mode you can write console.log(Infinity = 0) and there is no problem with that. This will return 0 as inspected and Error “TypeError: “Infinity” is read-only”
We can use this feature into a function. For example:

// Non-strict code...
     "use strict";
    // Define your library strictly...
// Non-strict code...

But, if you activate it you’ll see a lot of problems on the console. To avoid that, try to write a clean code.

You Might Also Like

Leave a Reply