?. (1) 썸네일형 리스트형 [JS] optional chaining (?.) JS에서 optional chaining 이라는 것이 있는데, 객체의 속성에 접근하거나 함수를 호출할 때 물음표와 온점을 같이 쓰는 것이다. 만약 접근하려는 객체가 null 이거나 undefined이면 오류를 내보내는 대신에 undefined를 내보내도록 한다. 위 이미지를 보면, person이라는 객체가 선언되어있다. 우선 person에 없는 속성인 names에 접근 후 다시 first 속성에 접근하려고 하면 Uncaught TypeError: Cannot read properties of undefined (reading 'first') 에러가 발생한다. >> person.names ==> undefined >> person.names.first ==> undefined.first --> 에러 발생 .. 이전 1 다음