Possible to enable “strict mode” in FireBug and Chrome's console?

一笑奈何 提交于 2019-11-28 08:10:29

The firebug console works by wrapping all the code in an "eval" call so the first statement in your script is no longer "use strict" - hence it is disabled. You could try wrapping your code in a function to enforce "use strict" for that particular function but the best solution I know of is to skip the console and test straight in the page itself.

use shift+enter to input 'use strict'

like this

If you are just testing a single function in the console, you can also just put 'use strict' as the first line in the function declaration.

On Chrome go to "chrome://flags", then "Enable Experimental JavaScript". Relaunch.

Chrome: put 'use strict'; prefix in your code line (and/or shift+enter for multiline)

'use strict'; var foo = 2; delete foo;
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!