javascript: What is a NOT NOT? (!! operator )

Possible Duplicate:
What is the !! operator in JavaScript?

What is a not not in javascript I have seen this a few times :)

function foo(){
    return !!(window.history);
}

i believe it is used for enforcing boolean types...

for example

if("true" == true){
    alert("1");
}else{
    if(!!"true" == true){
        alert("2");
    }
}

alerts 2 not 1


我认为它曾经[不那么]隐式地将值转换为布尔类型

链接地址: http://www.djcxy.com/p/12650.html

上一篇: myVar = !! someOtherVar

下一篇: javascript:什么是NOT NOT? (!!运营商)