2 ms·
if the first term is undefined, isDone will be undefined, not false. At least in Javascript. && returns the falsy value on the left side of the expression if i
by allannienhuis 7y ago
if the first term is undefined, isDone will be undefined, not false. At least in Javascript.
&& returns the falsy value on the left side of the expression if it evaluates to a falsy value
(undefined && true) evaluates to undefined
correspondingly || returns the truthy value (which might be an object) on the left hand side if evaluates truthy. That's useful for expressions like this:
const a = b || 'default value';
!! turns truthy/falsy values into booleans.
- deleted 7y ago[deleted]
- coldtea 7y agoTrue, !! is still needed to get a True/False instead of the truthy/falsey value...