可能重复:
What is the !! (not not) operator in JavaScript?
Reference - What does this symbol mean in JavaScript?如何使用!!表达?
我找JS代码写这样的:!未定义,!!假;
jquery的源代码(jQuery的1.7.0.js:748线):
grep: function(elems, callback, inv) {
var ret = [], retVal;
inv = !!inv;
// Go through the array, only saving the items
// that pass the validator function
for (var i = 0, length = elems.length; i < length; i++){
retVal = !!callback(elems[ i ], i);
if (inv !== retVal) {
ret.push(elems[ i ]);
}
}
return ret;
}
那么,'!expr'呢? '!(!expr)'做什么?把小部分放在一个更大的部分:) – 2012-03-09 05:28:00
可能重复[参考 - 这个符号在JavaScript中意味着什么?](http://stackoverflow.com/questions/9549780/reference-what-does-this-symbol-意思是在JavaScript中),更具体的[什么是! (不是)运营商在JavaScript?](http://stackoverflow.com/questions/784929/what-is-the-not-not-operator-in-javascript) – 2012-03-09 05:30:14