-2

I am not a JavaScript expert, but I'm reading the code and found out that there's a statement like this.

if(!~dssClass.indexOf("hideDiv")

What's the "~" mean in this statement?

Thanks

R.Spark
  • 955
  • 2
  • 16
  • 22

1 Answers1

1

It's bitwise NOT: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Expressions_and_Operators

"take the result of the indexOf lookup, bitwise invert it, then take the logical NOT of that"

Marc B
  • 356,200
  • 43
  • 426
  • 500
  • 1
    Please note this question is a duplicate and should be deleted – John Dvorak Jul 28 '14 at 20:51
  • @JanDvorak - Duplicate questions and answers shouldn't be deleted. – Derek 朕會功夫 Jul 28 '14 at 21:07
  • @Derek朕會功夫 not all duplicates are created equal. If all they do is copy some other question, keyword for keyword, and only accumulate worse answers than the original had, they are useless. If they ask the same question as the original in a different way, then sure, go ahead, keep it. They might be useful for googlers. – John Dvorak Jul 28 '14 at 21:13