我正在寻找与 php 函数等效的 javascriptisset()
。我已经尝试过此处描述的方法JavaScript isset() 等效项但在 firebug 中,出现错误
data.del is undefined //Firebug warning/error
if(typeof data.del[0].node != 'undefined') { // codes in my js file
并且在某些情况下
data is null //Firebug warning/error
if(typeof data.storyLine != 'undefined') { // codes in my js file
逻辑似乎可行,但我想知道为什么会出现错误?
基本上,我想检查是否data.del[0].node
or data.storyLine
是否成立?
isset() 使两张支票:如果变量已定义,则第一个,如果变量为空,则第二个。
您必须检查“未定义”情况和空情况,例如:
if (typeof data !== 'undefined' && data !== null)
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)