반응형

var a = null
undefined
a
null
!a
true
~a
-1

var b = undefined
undefined
b
undefined
!b
true
~c
-1

var c = false
undefined
c
false
!c
true
~c
-1

/*
==는 먄약 a==b이라고 했을때, a와 b가 '값'이 같은지를 판단해서 맞으면 true, 틀리면 false라고 한다.
===는 만약 a===b이라고 했을때, a와 b가 '값'과 '타입/형식'이 정확하게 같은지를 판단해서 true/false를 표현한다.
*/

// null과 undefined는 값은 같으나 타입이 다르기에 false가 뜬다.
a == b
true
a === b
false

a == c
false
a === c
false

b == c
false
b === c
false


여기서 포인트는 null이나 undefined 모두 !을 붙이면 true가 나타난다.










반응형