let thing = true thing = !thing thing === false // true
This is a Boolean value that is(
true)and then inverts it to (
let thing = "This string is truthy!" thing = !thing thing === false // true
This is how the
! Operator converts the string value (truthy), to its Boolean counterpart
false,We can also use the
false, and vice versa.
Then it follows that
!!This inversion can be performed twice.
let thing = "This string is truthy!" thing = !!thing thing === true // true
This is a quicker way to convert a Boolean value to a value. Use
!!This will cause the value to be cast as
This could be done for the exact same result.
let thing = Boolean("This string is truthy!") thing === true // true
What is the difference? According to my knowledge, there’s no difference!
!! is more succinct, the argument could be made that it is more confusing syntactically than