Member-only story
Javascript “Bang, Bang. I Shot You Down” - Use of Double Bangs (!!) in Javascript.
How to keep from getting shot down while using double bangs

TLDR;
The !! (double bang) logical operators return a value’s truthy value.
Javascript ‘Truthy’ Values
In Javascript, every value has an associated boolean, true or false, value. For example, a null
value has an associated boolean value of false
. A string value, such as abc
has an associated boolean value of true
.
Values that are associated with boolean true
are said to be truthy. Values that are associated with boolean false
values are said to be falsy.
A full list of truthy values can be found here:
A full list of falsy values can be found here:
Boolean Operations
Certain operations, like conditional if
statements, will elect to use the associated boolean true/false
value instead of the value itself. In these cases, we can say that the value is being used in a boolean context and will be coerced, or forced to, its associated true/false
value.
The First Shot — A Single Bang!
In Javascript, the exclamation mark (“!”) symbol, called a “bang,” is the logical “not” operator. Placed in front of a boolean value it will reverse the value, returning the opposite.