What's The Difference Between Double Exclamation Operator And Boolean() In Javascript?
I know that !!variable will convert variable into a boolean value and the function Boolean(), according to the ecma262 spec, will also perform a type conversion by calling ToBoolea
Solution 1:
They are the same, as the !
operator will call ToBoolean()
internally on its operand, and then flip that returned value, while Boolean()
will call ToBoolean()
internally on its argument.
Post a Comment for "What's The Difference Between Double Exclamation Operator And Boolean() In Javascript?"