JavaScript Intensive Tutorial--Strict mode

Source: Internet
Author: User

This article ish5eduAgency officialHTML5 Trainingtutorials, the main introduction:JavaScript Intensive Tutorials--Strict mode
 

avascript  Strict Mode (use strict) javascript  Strict mode (Strict mode) is run under strict conditions. Use   "use strict"   instruction "use strict"   instruction in  JavaScript 1.8.5  (ECMASCRIPT5) New in  . It is not a statement, but it is a literal expression that is ignored in the  JavaScript  old version. The purpose of the "use strict"   is to specify that the code executes under strict conditions. You cannot use undeclared variables in strict mode. Strict mode restrictions do not allow undeclared variables: "Use strict";x = 3.14;                 //  error   (x  undefined) The note object is also a variable. "Use strict";x = {p1:10, p2:20};      //  error   (x   undefined) does not allow the deletion of variables or objects. "Use strict";var x = 3.14;delete x;                 //  error not allowed to delete function. "Use strict"; function x (P1, P2)  {}; delete x;                 //  error   Do not allow variable names: "USe strict "; function x (P1, P1)  {};   //  error is not allowed to use octal:" Use strict "; var x = 010;             //   Error not allowed escape character: "Use strict";var x = \010;             //  error not allowed to assign value to read-only attribute: "Use strict"; var obj = {};o Bject.defineproperty (obj,  "x",  {value:0, writable:false});obj.x = 3.14;             //  An error is not allowed to assign a property that is read using the Getter method "use  Strict "; Var obj = {get x ()  {return 0} };obj.x = 3.14;             //  error not allowed to delete a property that is not allowed to be deleted: "Use strict";d elete  Object.prototype; //  error variable name cannot be used   "eval"   string: "Use strict"; var eval =  3.14;         //  error variable name cannot be used   "arguments"   string: "Use strict"; var arguments =  3.14;    //  error does not allow the use of the following statement: "Use strict";with  (Math) {X = cos ( 2)}; //  error due to some security reasons, the variable created in scope  eval ()   cannot be called: "Use strict";eval  ("var x =  2 ");alert  (x);

Click to enter JS Intensive tutorial

This article is from the "11721999" blog, please be sure to keep this source http://11731999.blog.51cto.com/11721999/1860509

JavaScript Intensive Tutorial--Strict mode

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.