可能重複:
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