Possible Duplicate:
What is the !! (not not) operator in JavaScript?
I've seen operator ! used like !!. For example
var filter = !!(document.body.filters);
If I'm not wrong it's equivalent var filters = typeof document.body.filters != 'undefined'?
Is it a good practice to use !!?
It's up to you. All !! does is "cast" its argument to a Boolean.
It's a common way to convert any return type to boolean (usually to avoid compilation warnings). And second: no, checking if type is "undefined" is mandatory anyway and "!!" can not cover it.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With