我收到以下javascript错误:
'value' is null or not an object
Run Code Online (Sandbox Code Playgroud)
有人可以让我知道在我使用的javascript中检查对象的值是否为NULL的最佳方法是什么:
if ((pNonUserID !== "") || (pExtUserID !== "")){
Run Code Online (Sandbox Code Playgroud)
这是正确的还是有更好的方法?
谢谢.
Chr*_*ian 13
你不必这样做:
var n=null;
if(n)alert('Not null.'); // not shown
if(!n)alert('Is null.'); // popup is shown
Run Code Online (Sandbox Code Playgroud)
你的错误暗示:
var n=null;
alert(n.something); // Error: n is null or not an object.
Run Code Online (Sandbox Code Playgroud)
在上面的例子中,应该使用这样的东西:
if(n)alert(n.something);
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
47719 次 |
| 最近记录: |