Can someone tell me what double exclamation points mean in javascript?
| SitePoint Sponsor |





Can someone tell me what double exclamation points mean in javascript?
John Saunders








I think of the double ex operator(!!) as a boolean converter-
it returns a boolean type true or false value for whatever data it operates on.
It is actually not a single operator, but two consecutive uses of the ! operator, which first reverses the true or false value of its operand, and then reverses the reversed value.
It is not perfect- sometimes a glass is half empty. But it can be relied on to return exactly one of exactly two possible values, and with a language as loose as javascript, that can be a real asset.
Bookmarks