What is the best way to check if a variable is set?
This question already has an answer here:
check it using typeof
if(typeof(a) != "undefined") {
//code goes here
}
Here are some related questions.
How can I check whether a variable is defined in JavaScript?
Test if a variable is defined in javascript?
if (typeof a !="undefined")
{
//write your code here
}
链接地址: http://www.djcxy.com/p/95010.html
上一篇: 检查变量是否定义了javascript
下一篇: 检查变量是否设置的最佳方法是什么?