Double negation converts a non-boolean to an inverted boolean value. This helps in checking the truthiness of a value, by representing it as a boolean value.
If the value is a string type, and it is an empty string, false will be returned. If it has some value then true will be returned.
If the value is a number type, and it is 0, false will be returned. If it has some number as a value then true will be returned.
Whereas null and undefined types will be checked for values, hence false will be returned.
Get PaperInFlames’s stories in your inbox
Join Medium for free to get updates from this writer.
Press enter or click to view image in full size
4. If the value is a boolean type, then true will be returned if the value is true else false will be returned.