The &&
operator will return the first non-truthy expression or the last evaluated expression if both are truthy.
In essence, by checking if e.originalEvent
exists, you ensure that if it does, the value of e.originalEvent.target
will be passed as the first parameter to func
. If e.originalEvent
doesn't exist, it will be undefined
, and in that scenario, undefined
will be passed to
a</code, skipping the evaluation of <code>e.originalEvent.target
.
Take into account the following examples:
console.log(1 && 2);
# 2
console.log(null && 2);
# null
console.log(undefined && 2);
# undefined
console.log(0 && 2);
# 0
Keep in mind: Only one argument is being passed, so by default, b
and c
will be undefined
.