2014-11-24 5 views
0
var obj = { 
    a: "value", 
    b: false 
}; 
// nonexistent properties 
console.log(!!obj.nonexistent); 

// existing properties 
console.log(!! obj.a); 

나는 !!의 의미를 모르겠다.JS에서 '!!'의 의미는 무엇입니까?

console.log(obj.nonexistent); -> undefined 나는 이것을 이해할 수있다. console.log(!obj.nonexistent); -> true 나는 이것을 이해할 수 없다. ?????????

console.log(!! obj.a); 나는 이것을 이해할 수 없습니다. ?????????

+0

이 잘 나는 마지막 보여줍니다 추측 * 거짓 *이 아닌가요? ... 대신에 * undefined * ... –

+1

참조 : http://stackoverflow.com/questions/784929/what-is-the-not-operator-in-javascript –

+1

이는 '!'를 한 번 적용한다는 의미입니다 그런 다음 다시 적용하십시오. –

답변

1

예를 들어, 고려 : 다음

null //null 

: 다음

!null //true 

:

!!null //false