Search code examples
javascriptoperatorscomparison-operators

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);
}

Solution

  • 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