Wednesday, February 18, 2015

javascript double negative !!

I was looking at htmlbars on github and saw something new to me.


if(!!value)...


In other words, if value is falsey. If it's unidentified, the first ! will return false, then the second will return true due to negation.


A quick search turned up that this is borrowed from C. It's sort of like a cast to boolean.

No comments:

Post a Comment