And and Or in JS
Monday, July 11th, 2005The logical and (&&) and the logical or (||) are two really useful operators in JS. The following holds true:
a || b results in a if Boolean(a) == true, otherwise b
a && b results in b if Boolean(a) == true, otherwise a
Using this one can often simplify expression a lot. For example:
var el = e.target [...]