[英]What is the correct way to check if a global variable exists?
JSLint 沒有將此作為有效代碼傳遞:
/* global someVar: false */
if (typeof someVar === "undefined") {
var someVar = "hi!";
}
正確的方法是什么?
JSLint 沒有將此作為有效代碼傳遞:
/* global someVar: false */
if (typeof someVar === "undefined") {
var someVar = "hi!";
}
什么是正確的方法?
JSLint 沒有將此作為有效代碼傳遞:
/* global someVar: false */
if (typeof someVar === "undefined") {
var someVar = "hi!";
}
什么是正確的方法?
JSLint 沒有將此作為有效代碼傳遞:
/* global someVar: false */
if (typeof someVar === "undefined") {
var someVar = "hi!";
}
什么是正確的方法?
JSLint 沒有將此作為有效代碼傳遞:
/* global someVar: false */
if (typeof someVar === "undefined") {
var someVar = "hi!";
}
什么是正確的方法?
JSLint 沒有將此作為有效代碼傳遞:
/* global someVar: false */
if (typeof someVar === "undefined") {
var someVar = "hi!";
}
什么是正確的方法?
JSLint 沒有將此作為有效代碼傳遞:
/* global someVar: false */
if (typeof someVar === "undefined") {
var someVar = "hi!";
}
什么是正確的方法?
JSLint 沒有將此作為有效代碼傳遞:
/* global someVar: false */
if (typeof someVar === "undefined") {
var someVar = "hi!";
}
什么是正確的方法?
JSLint 沒有將此作為有效代碼傳遞:
/* global someVar: false */
if (typeof someVar === "undefined") {
var someVar = "hi!";
}
什么是正確的方法?
JSLint 沒有將此作為有效代碼傳遞:
/* global someVar: false */
if (typeof someVar === "undefined") {
var someVar = "hi!";
}
什么是正確的方法?
JSLint 沒有將此作為有效代碼傳遞:
/* global someVar: false */
if (typeof someVar === "undefined") {
var someVar = "hi!";
}
什么是正確的方法?
如果您不確定是否定義了全局變量,您可以隨時嘗試訪問它並查看會發生什么。
function node_env(name) {
try {
return process.env[name];
} catch (ignore) {}
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.