jquery - Javascript && operator - clarification? -


this question has answer here:

edit : quote removed. not related question.

question

how come (when truthy) takes last value ?

examples :

f= 1 && 2 && 3 //3

f= 'k' && 'd' && 's' //'s'

p.s. : i've noticed when investigating pub/sub using $.callbacks

enter image description here

operator && acts if-statement. short-circuit occurs if value is false. otherwise, keeps evaluating statements.

when write a && b means: a ? b : a. similarly, a || b means: a ? : b.


Comments

Popular posts from this blog

java.util.scanner - How to read and add only numbers to array from a text file -

rewrite - Trouble with Wordpress multiple custom querystrings -