javascript判断变量是否为空的方法

javascript判断字符串变量是否为空的方法
代码如下
<pre>

if (typeof(ndesc)=="undefined" || ndesc=='' || ndesc==null)
{
ndesc="1111!";
}
</pre>

 

ps:ndesc 变量没有初始化 typeof(ndesc) 都是undefined

 

 

判断数字是否为空

var startv = parseInt($('#myTargetElement').text());
if (isNaN(startv)) {
startv = 0;
}

 

 

posted @ 2019-11-16 19:13  newmiracle宇宙  阅读(10398)  评论(0编辑  收藏  举报