[英]What is the correct way to check if a global variable exists?
JSLint is not passing this as a valid code: JSLint 没有将此作为有效代码传递:
/* global someVar: false */
if (typeof someVar === "undefined") {
var someVar = "hi!";
}
What is the correct way?正确的方法是什么?
JSLint is not passing this as a valid code: JSLint 没有将此作为有效代码传递:
/* global someVar: false */
if (typeof someVar === "undefined") {
var someVar = "hi!";
}
What is the correct way?什么是正确的方法?
JSLint is not passing this as a valid code: JSLint 没有将此作为有效代码传递:
/* global someVar: false */
if (typeof someVar === "undefined") {
var someVar = "hi!";
}
What is the correct way?什么是正确的方法?
JSLint is not passing this as a valid code: JSLint 没有将此作为有效代码传递:
/* global someVar: false */
if (typeof someVar === "undefined") {
var someVar = "hi!";
}
What is the correct way?什么是正确的方法?
JSLint is not passing this as a valid code: JSLint 没有将此作为有效代码传递:
/* global someVar: false */
if (typeof someVar === "undefined") {
var someVar = "hi!";
}
What is the correct way?什么是正确的方法?
JSLint is not passing this as a valid code: JSLint 没有将此作为有效代码传递:
/* global someVar: false */
if (typeof someVar === "undefined") {
var someVar = "hi!";
}
What is the correct way?什么是正确的方法?
JSLint is not passing this as a valid code: JSLint 没有将此作为有效代码传递:
/* global someVar: false */
if (typeof someVar === "undefined") {
var someVar = "hi!";
}
What is the correct way?什么是正确的方法?
JSLint is not passing this as a valid code: JSLint 没有将此作为有效代码传递:
/* global someVar: false */
if (typeof someVar === "undefined") {
var someVar = "hi!";
}
What is the correct way?什么是正确的方法?
JSLint is not passing this as a valid code: JSLint 没有将此作为有效代码传递:
/* global someVar: false */
if (typeof someVar === "undefined") {
var someVar = "hi!";
}
What is the correct way?什么是正确的方法?
JSLint is not passing this as a valid code: JSLint 没有将此作为有效代码传递:
/* global someVar: false */
if (typeof someVar === "undefined") {
var someVar = "hi!";
}
What is the correct way?什么是正确的方法?
JSLint is not passing this as a valid code: JSLint 没有将此作为有效代码传递:
/* global someVar: false */
if (typeof someVar === "undefined") {
var someVar = "hi!";
}
What is the correct way?什么是正确的方法?
If you are not sure whether a global variable is defined, you can always try accessing it and see what happens.如果您不确定是否定义了全局变量,您可以随时尝试访问它并查看会发生什么。
function node_env(name) {
try {
return process.env[name];
} catch (ignore) {}
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.