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 ToBoolean(value).
My question is: what's the difference? Is !! better in performance than Boolean() ?
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With