자바스크립트에서 null과 undefined 체크를 위해서는 동등 연산자가(==) 아닌 일치 연산자를(===) 사용해야 한다.
또는 NOT 연산자를 사용한다.
만약 null과 undefined 둘 다 걸러주기 위함이라면 동등 연산자(==)를 사용한다.
const a = undefined;
const typeofA = typeof(a); //undefined
const b = null
const typeofB = typeof(b); //object
console.log(a==b);
//true
console.log(a===b);
//false
console.log(typeofA === typeofB);
//false
동등 연산자를 사용하여 null 과 undefined를 비교하면 true가 반환된다.
일치 연산자를 사용하여 비교하면 false가 반환된다.
if(event.currentTarget == null){
return event.currentTarget
}
사용하는 목적에 따라 동등 연사자를 사용할 수 있지만 반드시 알고 작성하자!