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

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

    Use Strict is used to show common and repeated errors so that it is handled differently , and changes the way java script runs , such changes are :

    • Prevents accidental globals

    • No duplicates

    • Eliminates with

    • Eliminates this coercion

    • Safer eval()

    • Errors for immutables

    you can also read this article for the details

提交回复
热议问题