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

前端 未结 28 3716
半阙折子戏
半阙折子戏 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:39

    There's a good talk by some people who were on the ECMAScript committee: Changes to JavaScript, Part 1: ECMAScript 5" about how incremental use of the "use strict" switch allows JavaScript implementers to clean up a lot of the dangerous features of JavaScript without suddenly breaking every website in the world.

    Of course it also talks about just what a lot of those misfeatures are (were) and how ECMAScript 5 fixes them.

提交回复
热议问题