Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

What are the limitations of JavaScript strict mode

2025-01-29 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/01 Report--

Most people do not understand the knowledge points of this article "what are the restrictions on the strict mode of JavaScript?", so the editor summarizes the following, detailed content, clear steps, and has a certain reference value. I hope you can get something after reading this article. Let's take a look at this article, "what are the restrictions of JavaScript strict mode?"

The limitation of strict mode

Undeclared variables are not allowed:

"use strict"

Function x (p1, p1) {}; / / error report

Object is also a variable.

"use strict"

Var x = 010; / / error report

Deletion of variables or objects is not allowed.

"use strict"

Var x = 3.14

Delete x; / / error report

Deletion of functions is not allowed.

"use strict"

Function x (p1, p2) {}

Delete x; / / error report

Duplicate names of variables are not allowed:

"use strict"

Function x (p1, p1) {}; / / error report

Octal is not allowed:

"use strict"

Var x = 010; / / error report

Escape characters are not allowed:

"use strict"

Var x =\ 010; / / error report

Assigning values to read-only properties is not allowed:

"use strict"

Var obj = {}

Object.defineProperty (obj, "x", {value:0, writable:false})

Obj.x = 3.14; / / error report

It is not allowed to assign a value to an attribute read using the getter method

"use strict"

Var obj = {get x () {return 0}}

Obj.x = 3.14; / / error report

Deletion of an attribute that is not allowed to be deleted is not allowed:

"use strict"

Delete Object.prototype; / / error report

Variable names cannot use the "eval" string:

"use strict"

Var eval = 3.14; / / error report

Variable names cannot use the "arguments" string:

"use strict"

Var arguments = 3.14; / / error report

The following statements are not allowed:

"use strict"

With (Math) {x = cos (2)}; / / error report

For some security reasons, variables created in scope eval () cannot be called:

"use strict"

Eval ("var x = 2")

Alert (x); / / error report

The above is the content of this article on "what are the restrictions on the strict mode of JavaScript". I believe we all have a certain understanding. I hope the content shared by the editor will be helpful to you. If you want to know more about the relevant knowledge, please pay attention to the industry information channel.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report