What does “use strict” do in JavaScript, and what is the reasoning behind it?

前端 未结 28 3084
半阙折子戏
半阙折子戏 2020-11-21 06:05

Recently, I ran some of my JavaScript code through Crockford\'s JSLint, and it gave the following error:

Problem at line 1 character 1: Missing \"use

28条回答
  •  北恋
    北恋 (楼主)
    2020-11-21 06:37

    Strict mode makes several changes to normal JavaScript semantics:

    • eliminates some JavaScript silent errors by changing them to throw errors.

    • fixes mistakes that make it difficult for JavaScript engines to perform optimizations.

    • prohibits some syntax likely to be defined in future versions of ECMAScript.

    for more information vistit Strict Mode- Javascript

提交回复
热议问题