<aside>
목차
</aside>
Array.prototype.find() - JavaScript | MDN
undefinded를 할당하는가?<aside> 🧐
실습 중 해당하는 객체 타입(CatType)만을 할당 했더니 오류가 발생되었다.
이를 해결하기위해 undefinded를 할당 했어야 했는데, 왜 undefinded를 할당하는지 의문점이 들어 정리한다.
</aside>
문제 코드
const cat: CatType = Cat.find((cat) => {
return cat.id === params.id;
});

해결 코드
const cat: CatType | undefined = Cat.find((cat) => {
return cat.id === params.id;
});
Array.prototype.find() 반환값위 코드에서 사용하는 find() 함수는 Array.prototype.find()이다.

Array.prototype.find()