Monday, June 3, 2024
 Popular · Latest · Hot · Upcoming
66
rated 0 times [  68] [ 2]  / answers: 1 / hits: 73652  / 12 Years ago, wed, july 18, 2012, 12:00:00

Possible Duplicate:

return !1 in javascript






In a JavaScript file I had to read today, there was a line where a variable was declared like a factorial, like this :



var myVariable = !1;


and then something similar was used as parameter in a function like this :



return variable.myFunction(!0);


Can anyone explain me what the exclamation mark means in this context and eventually, why this is generally used for (benefits) ?



Thank you in advance !


More From » javascript

 Answers
11

The ! is the boolean NOT operator.



NOT (!): toggles a statement from true to false or from false to true.



!0 = true
!1 = false


This is a brilliant introduction to boolean operators and their use in javascript.


[#84167] Tuesday, July 17, 2012, 12 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
mckinley

Total Points: 15
Total Questions: 101
Total Answers: 94

Location: Liechtenstein
Member since Fri, Sep 11, 2020
4 Years ago
;