开发者

&& Operator precendence in JavaScript

if(e.FN === ' ' && e开发者_如何学运维.GN === ' ' && e.LN === ' ' && e.DB === ' '){

This condition is never evaluated at all. Is this the way to check if all the values are null.


Right now you are checking if those values are all equal to a Space. The === not only compares the values but ensures they are the same type. However, if e.FN is null both e.FN == ' ' and e.FN === ' " will always return false. I think what you want is

if(e.FN === null && e.GN === null && e.LN === null && e.DB === null)

or even better, if you don't care if they are null, undefined or 0 you could do

if(e.FN && e.GN && e.LN && e.DB)


try:

if(e.FN === null && e.GN === null && e.LN === null && e.DB === null){  


To check if all the values are null you should do:

if(e.FN === null && e.GN === null && e.LN === null && e.DB === null){

if the first value is not null javascript doesn't evaluate other condition, because if the first condition is false it's not possible for all the conditions to be true.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜