"Use strict"; The correct use of

Source: Internet
Author: User

"Use strict"; When placed in the starting position of a JavaScript file or function (I am not sure if the script tag can begin), you can turn on strict mode. Otherwise-in the case of a JavaScript file that is not at the beginning of the file and not at the beginning of the function-it is a generic string that is not used, except that it wastes a few bytes and is of little use. It is generally recommended to add "use strict" at the beginning of all functions (or all outermost functions); The command starts strict mode, and it is never recommended to write the global "use strict" at the beginning of the file-instead, some ES validators give a warning.

Global "use strict" why not? One important reason is that when a file is merged, some files are in strict mode, while others are not. At this time these are the strict mode of the file, the merge, the string to the middle of the file, not only does not indicate strict mode, but in the compression after the waste of bytes.

Excerpted from http://www.guokr.com/post/534018/

"Use strict"; The correct use of

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.