使用“使用严格”作为“使用强”的备份

Using "using strict" as a backup for "use strong"

本文关键字:使用强 备份 使用严格 使用 作为      更新时间:2023-09-26

有没有办法使用"use strong";"use strict";用作备份? 因为它看起来谷歌浏览器是目前唯一支持"use strong";的浏览器。

你总是可以将你的代码包装在一个立即调用的函数表达式中,在它外面是"use strict",在里面是"use strong"(所以如果浏览器支持它,它优先):

"use strict"
(function(){
    "use strong";
    //your code here
})();