SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    Git-R-Done
    Join Date
    Nov 2001
    Posts
    1,194
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Double exclamations

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

  2. #2
    SitePoint Guru
    Join Date
    Sep 2006
    Posts
    731
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by JohnSaunders View Post
    Can someone tell me what double exclamation points mean in javascript?
    It's a double use of the inversion operator: !, which can be used to convert undefined to false.
    Tab-indentation is a crime against humanity.

  3. #3
    SitePoint Guru
    Join Date
    Apr 2006
    Posts
    802
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    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

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •