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 callToBoolean()internally on its operand, and then flip that returned value, whileBoolean()will callToBoolean()internally on its argument.