簡體   English   中英

如何使用JavaScript檢查變量是否不為null或為空字符串?

[英]How can I check if a variable is neither null or the empty string with javascript?

我一直在做以下事情:

if (json.RowKeyNew != "") {
    updateGridMeta(entity, json.PartitionKey, json.RowKeyNew, row, tab);
}

但是,如果json.RowKeyNew為null,則滿足if條件,這不是我想要的。 如何檢查不為null且不是“”的內容?

if (json.RowKeyNew != undefined && json.RowKeyNew != "") {};

嘗試...

if (json.RowKeyNew) {
    updateGridMeta(entity, json.PartitionKey, json.RowKeyNew, row, tab);
}
if (json.RowKeyNew) 

只是將varible放入if條件中,如果具有某些值,則返回true,否則返回false

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM