In ECMAScript5, what's the scope of “use strict”?

后端 未结 4 1266
囚心锁ツ
囚心锁ツ 2020-12-05 09:52

What scope does the strict mode pragma have in ECMAScript5?

\"use strict\";

I\'d like to do this (mainly because JSLint doesn\'t complain a

4条回答
  •  被撕碎了的回忆
    2020-12-05 10:04

    EDIT It appears I was incorrect. Please see Jeff Walden's answer below.

    Check out this answer to a related question: What does "use strict" do in JavaScript, and what is the reasoning behind it?

    Despite JSLint's complaints, you can (and should) use "use strict"; inside of a function if you only want that function to be in strict mode. If you use it in the global context then it will force all your code to be in strict mode. Short answer: yes, it will block your use of eval.

提交回复
热议问题