Rya*_*yan 1 javascript firefox global-variables firefox-addon
我将我的插件提交给AMO目录,编辑回来了:
There are still a number of variables being leaked to the global scope,
probably because you're using them undeclared like...
Run Code Online (Sandbox Code Playgroud)
他没有提到所有的问题变量,无论如何都知道哪些在全球范围/被泄露?
我有一大堆变量,它们需要花费很长时间才能确保它们用"var"正确声明.
请帮忙!
谢谢!
如果您正在尝试跟踪由于省略而可能已隐式声明为全局的变量,则var
可以运行代码strict mode
.ReferenceError
如果您尝试使用未声明属性的变量,这将为您提供.
(function() {
"use strict"; // <-- this runs code inside this function in strict mode
// your code...
test = 'tester'; // gives a ReferenceError
})();
Run Code Online (Sandbox Code Playgroud)
您需要在支持的浏览器中运行它,例如Firefox 4或更高版本.该"use strict";
声明性将确保该函数内的任何代码将使用的严格模式的规则进行评估.
归档时间: |
|
查看次数: |
434 次 |
最近记录: |