发布时间: 2016-07-17 07:39:00
直接用if就可以.
参考: http://stackoverflow.com/questions/5515310/is-there-a-standard-function-to-check-for-null-undefined-or-blank-variables-in
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 */ }