Continuing the discussion from Discouraged about how my code looks :
const getI = r => +!r?.employee?.foo
The !
is the logical NOT operator, so it will take whatever r?.employee?.foo
returns and convert that value to its opposing boolean value (i.e if r?.employee?.foo
returned a falsy value then !
will convert it to true
and vice versa).
The +
operator will then forcibly convert that boolean value into a number (either 0
or 1
).
1 Like
This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.