What ‘use strict’ means for in JavaScript
Chokri K'
Posted on August 27, 2019
“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... (function(){ "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.
The post What ‘use strict’ means for in JavaScript appeared first on C.Khalifa.
Posted on August 27, 2019
Join Our Newsletter. No Spam, Only the good stuff.
Sign up to receive the latest update from our blog.