直接用if就可以.
if( value ) {
}
will evaluate to true if value is not:
null
undefined
NaN
empty string ("")
0
false
ps. 其实这么死扣语法的事情,我是不喜欢的. 特别是:
if(typeof variable==='undefined' || variable===null) {
/* do your stuff */
}
直接用if就可以.
if( value ) {
}
will evaluate to true if value is not:
null
undefined
NaN
empty string ("")
0
false
ps. 其实这么死扣语法的事情,我是不喜欢的. 特别是:
if(typeof variable==='undefined' || variable===null) {
/* do your stuff */
}