Strict mode in JavaScript (translated)

Source: Internet
Author: User

The "Use strict" state indicates that the browser uses strict mode, which is a relatively small and secure set of features in JavaScript.

Feature List (not fully enumerated)

  1. Defining global variables is not allowed. (Captures spelling errors for variables and variable names that are not declared with Var)
  2. A declaration that causes a silent failure in strict mode throws an exception (declares NaN = 5)
  3. Attempting to delete a property that cannot be deleted throws an exception (delete object. Prototype
  4. All property names in an object are unique (var x = {x1: "1", X1: "2"})
  5. The parameter name of the function must be unique (function sum (x, x) {...} )
  6. Disables the use of octal numeric syntax (var x = 023; Some developers mistakenly think that the previous 0 does not change the numbers)
  7. Prohibit use with keyword
  8. Eval does not introduce new variables in strict mode
  9. Prohibit Delete declaration variable (delete x)
  10. binding or assigning eval and arguments in any form is prohibited
  11. Strict mode does not synchronize the values of the arguments object to the parameter. (for example, in the function sum (A, b) {return arguments[0] + b}, this is written because Arguments[0] is bound to a, and so on. in normal mode, for a function where the first parameter is ARG, the value of ARG is assigned to Arguments[0] and vice versa (unless there are no arguments, or arguments[0] is deleted). In strict mode, the arguments object of the function saves the original arguments when the function is called. The value of arguments[i] does not change with the value of the corresponding parameter, and the value of the parameter with the same name will not change with the value of the corresponding arguments[i].
  12. Arguments.callee is no longer supported.

Translated from: http://stackoverflow.com/questions/1335851/ What-does-use-strict-do-in-javascript-and-what-is-the-reasoning-behind-it & Answerd by Gprasant

A more detailed description of the Mdn:https://developer.mozilla.org/zh-cn/docs/web/javascript/reference/strict_mode

RELATED links: https://tc39.github.io/ecma262/#sec-strict-mode-of-ecmascript

http://yanhaijing.com/es5/#about

Strict mode in JavaScript (translated)

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.