Thursday, October 3, 2013

The !! operator in JavaScript

While walking through a Single Page Application codebase I noticed the usage of the !! operator.

No clue what it means but StackOverflow brought the rescue.

“The !! operator will convert a value to a boolean first and than invert the result.”

JavaScript keeps surprising me…

1 comment:

Anonymous said...

I think it is a type cast trick. It changes truthy values to boolean true and falsy values to boolean false. Useful when assigning something to a valuable or property to make sure that it is of boolean type.