legendary Cast-to-bool 'operator', "bang, bang you're boolean"
Coerces Object to boolean. If it was falsey (e.g. 0,
null
, undefined
, etc.), it will be false
, otherwise, true
.
!oObject //Inverted boolean
!!oObject //!! converts the value to the right of it to its equivalent boolean value
true === !!10
false === !!0
So !! is not an operator, it's just the ! operator twice. It is the double-use of ! -- which is the logical "not" operator.
The "falsey" values are:
false
NaN
undefined
null
""
(empty string)0
No comments:
Post a Comment