![](https://img1.daumcdn.net/thumb/R750x0/?scode=mtistory2&fname=https%3A%2F%2Fblog.kakaocdn.net%2Fdn%2FbZhwIq%2FbtqT0tVbItK%2Fmx8cvpJQLdWkH4NVpknhc0%2Fimg.png)
개발관련/자바스크립트 팁
실무에서 값을 할당 할때 많이 사용하는 자바스크립트 연산자
or 연산자 ( || ) const detaultValue = param || "value"param 변수에 falsy 값 ("" , null, undefined) 등 값이 들어올 경우 기본값을 주기 위해 사용한다. 널 병합 연산자 ( ?? ) const foo = null ?? 'default string'; console.log(foo); // expected output: "default string" const baz = 0 ?? 42; console.log(baz); // expected output: 0바로 위의 or 연산자의 경우 0,"" 가 모두 falsy 값이기 때문에 null,undefined 와 0,"" 를 구분할수 없다. 이를 구분 해주기 위한 연산자 이다. and 연..