在js中判断 ruby的 .present?
访问量: 2336
直接用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 */ }