in some es6 code I see following:
let layer_combined = layers.map(getLayer).filter(l => !!l);
what is the meaning of !! in the filter() return?
in some es6 code I see following:
let layer_combined = layers.map(getLayer).filter(l => !!l);
what is the meaning of !! in the filter() return?
It's a way of casting to a boolean with double negation.
A singular !
negation produces a true/false value, but it's the opposite of what you want. Double negation produces a true/false value which matches the original intent.
Try it:
!!0 // false
!!1 // true
!!"test" // true
!!null // false