亚洲国产日韩欧美一区二区三区,精品亚洲国产成人av在线,国产99视频精品免视看7,99国产精品久久久久久久成人热,欧美日韩亚洲国产综合乱

JavaScript strict mode (use strict)

JavaScript strict mode (use strict)

JavaScript strict mode (strict mode) runs under strict conditions.

Use the "use strict" directive

The "use strict" directive is new in JavaScript 1.8.5 (ECMAScript5).

It is not a statement, but a literal expression, which will be ignored in older versions of JavaScript.

The purpose of "use strict" is to specify that the code is executed under strict conditions.

You cannot use undeclared variables in strict mode.

The main purposes of establishing "strict mode" are as follows:

- Eliminate some unreasonable and imprecise aspects of Javascript syntax and reduce some weird behaviors;

- Eliminate some insecurities in code running and ensure the safety of code running;

- Improve compiler efficiency and increase running speed;

- Pave the way for new versions of Javascript in the future .

1. Overview

In addition to the normal operating mode, ECMAscript 5 adds a second operating mode: "strict mode". As the name suggests, this mode makes Javascript run under stricter conditions.

2. Why use strict mode

- Eliminate some unreasonable and imprecise aspects of Javascript syntax and reduce some weird behaviors;

- Eliminate some inconveniences in code running A safe place to ensure the safety of code running;

- Improve compiler efficiency and increase running speed;

- Pave the way for new versions of Javascript in the future.

"Strict Mode" reflects the more reasonable, safer and more rigorous development direction of Javascript. Mainstream browsers, including IE 10, already support it, and many large projects have begun to fully embrace it.

On the other hand, the same code may have different running results in "strict mode"; some statements that can be run in "normal mode" will not be able to be run in "strict mode" run. Mastering these contents will help you understand Javascript in more detail and make you a better programmer.

3. Enter the flag

"use strict";

4.How to call

4.1For a single script

 

Continuing Learning
||
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> </head> <body> <h1>使用 "use strict":</h1> <h3>嚴格模式不允許使用保留關鍵字。</h3> <p>瀏覽器按下 F12 開啟調(diào)試模式,查看報錯信息。</p> <script> "use strict"; var public = 1500; // 報錯 </script> </body> </html>
submitReset Code