Posts 일치연산자(===)와 동등연산자(==)
Post
Cancel

일치연산자(===)와 동등연산자(==)

1. 일치 연산자 ===를 사용하여 null과 undefined를 비교하면

두 값의 자료형이 다르기 때문에 일치 비교 시 거짓이 반환됩니다.

1
alert(null === undefined); // false

2. 동등 연산자 ==를 사용하여 null과 undefined를 비교하면

동등 연산자를 사용해 null과 undefined를 비교하면 특별한 규칙이 적용돼 true가 반환됩니다. 두 값은 자기들끼리는 잘 어울리지만 다른 값들과는 잘 어울리지 못하죠.

1
alert(null == undefined); // true

출처: 모던 javascript tutorials

This post is licensed under CC BY 4.0 by the author.

React Hooks - useRef()

scroll 속성 집고 넘어가기!

Comments powered by Disqus.