url = 'http://javascript.p2hp.com/';
), at this time The JavaScript interpreter automatically creates this variable for you. In order to make the code more rigorous, strict mode was introduced in JavaScript. Once strict mode is used, those imprecise syntaxes are no longer allowed.
What is strict mode
Strict mode was introduced in ECMAScript5 (ES5). In strict mode, JavaScript has stricter syntax requirements, and some code that can run in normal mode will not run in strict mode.
Add strict mode, mainly for the following purposes:
- Eliminate some unreasonable and imprecise places in JavaScript syntax;
- Eliminate some unsafe places in the code to ensure the safe operation of the code;
- Improve the efficiency of JavaScript programs;
- Lay the groundwork for future versions of JavaScript.
At present, mainstream browsers, including IE10 and later versions, already support strict mode, and JavaScript is developing in a more reasonable, secure, and rigorous direction.
Enable strict mode
To enable strict mode, you just need to add "use strict";
or 'use strict';
at the beginning of your JavaScript script
…
The post JS strict mode (use strict) in detail first appeared on Lenix Blog .
This article is reprinted from https://blog.p2hp.com/archives/9798
This site is for inclusion only, and the copyright belongs to the original author.