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
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
Post a Comment