4

Possible Duplicate:
What is the !! (not not) operator in JavaScript?

I just came across the code that uses !!, which means logical not not to me.

  app.isArray = Array.isArray || function(object) {
    return !!(object && object.concat
              && object.unshift && !object.callee);
  };

What is the different between using !! and not using it?

(my guess is !! will convert the result to Boolean type. if my guess is correct, why is it so?)

Community
  • 1
  • 1
Mifeng
  • 1,477
  • 14
  • 25
  • @WesleyMurch thanks. I tried searching it, but did not fint it. Maybe I need to improve my search keywords. :) – Mifeng Aug 01 '12 at 07:24
  • 2
    No it's hard to search for stuff like that. Only way I found it is through here: http://stackoverflow.com/questions/9549780/reference-what-does-this-symbol-mean-in-javascript (anyone feel free to cast reopen votes please!!!) – Wesley Murch Aug 01 '12 at 07:25
  • @WesleyMurch thanks again. The link is really helpful. – Mifeng Aug 01 '12 at 07:32

1 Answers1

5

!! Just inverts the content double into a boolean value. Here are some examples:

!! true === true
!! false === false
rekire
  • 45,039
  • 29
  • 149
  • 249