4 ms·
That's what !! is for!! :)
by allannienhuis 7y ago
That's what !! is for!! :)
- coldtea 7y agoWhich is not really needed here. isDone will be boolean, and the other ones are still Truthy / Falsey values...
- allannienhuis 7y agoif 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...