For the More Curious: Strict Mode

What is strict mode, and why does it exist? It was created as a cleaner mode of JavaScript, catching certain kinds of coding mistakes (like typos in variable names), steering developers away from some error-prone parts of the language, and disabling some language features that are just plain bad.

Strict mode provides a number of benefits. It:

  • enforces the use of the var keyword

  • does not require with statements

  • places restrictions on the way the eval function can be used

  • treats duplicate names in a function’s parameters as a syntax error

All this just for adding the 'use strict' directive to the top of a function. As a bonus, the 'use strict' directive is ignored by older browsers that do not support it. (These browsers simply see the directive as a string.)

You can read more about strict mode on the MDN at developer.mozilla.org/​en-US/​docs/​Web/​JavaScript/​Reference/​Strict_mode.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.138.105.215