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;

}