Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/loops/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何使用javascript检查变量是否为null或空字符串?_Javascript - Fatal编程技术网

如何使用javascript检查变量是否为null或空字符串?

如何使用javascript检查变量是否为null或空字符串?,javascript,Javascript,我一直在做以下工作: if (json.RowKeyNew != "") { updateGridMeta(entity, json.PartitionKey, json.RowKeyNew, row, tab); } 但是,如果json.RowKeyNew为null,则满足if条件,这不是我想要的。如何检查不为null且不为“”的内容?请尝试 if (json.RowKeyNew) { updateGridMeta(entity, json.PartitionKey, jso

我一直在做以下工作:

if (json.RowKeyNew != "") {
    updateGridMeta(entity, json.PartitionKey, json.RowKeyNew, row, tab);
}
但是,如果json.RowKeyNew为null,则满足if条件,这不是我想要的。如何检查不为null且不为“”的内容?

请尝试

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

只要把variable放在if条件中,如果有值,它返回true,否则返回false


只需将varible置于if条件中,如果有某个值,它将返回true,否则将返回false

如果
json怎么办。RowKeyNew
是数字零吗?如果
json怎么办。RowKeyNew
是数字零吗?
if (json.RowKeyNew != undefined && json.RowKeyNew != "") {};
if (json.RowKeyNew)