javascript - How is this if statement working with comma? -


there if statement

if ((sliding || "window" == type) &&     nbcasement % 2 != 1 || sliding || "garage" == type || f({     name: "hinge" }),     nbcasement > 0 && !sliding && f({     name: "side"  }),     d && apiproperty) 

with && || , ,

i thought it's same code:

f({     name: "hinge" }); f({     name: "side" }); if ((sliding || "window" == type) &&     nbcasement % 2 != 1 || sliding || "garage" == type ||     nbcasement > 0 && !sliding &&     d && apiproperty) 

but result different thought.

how statement working? condition make f({name:xxx}) run?

the f defind

  var e = []           , f = function(a) {             d && d.blacklist && d.blacklist[a.name] || e.push(a)         }; 

the comma operator evaluates everything, before returning last value. snippet equivalent to

(sliding || "window" == type) && nbcasement % 2 != 1 || sliding || "garage" == type || f({     name: "hinge" }); nbcasement > 0 && !sliding && f({     name: "side" }); if (d && apiproperty) 

which can cleaned , prettified to

if (!sliding) {     if (("window" != type || nbcasement % 2 == 1) && "garage" != type)         f({             name: "hinge"         });     if (nbcasement > 0)         f({             name: "side"         }); } if (d && apiproperty) 

Comments

Popular posts from this blog

php - Wordpress website dashboard page or post editor content is not showing but front end data is showing properly -

How to get the ip address of VM and use it to configure SSH connection dynamically in Ansible -

javascript - Get parameter of GET request -