find() undefined 오류

개발봇·2021년 6월 22일
0

잡앗으!크립트

목록 보기
1/1

https://developer.mozilla.org/ko/docs/Web/JavaScript/Reference/Global_Objects/Array/find

const array1 = [5, 12, 8, 130, 44];

const found = array1.find(element => {
  const a = 5;
  element === a;
});

console.log(found);
> undefined

https://stackoverflow.com/questions/50817412/array-prototype-find-returns-undefined-in-async-function

const array1 = [5, 12, 8, 130, 44];

const found = array1.find(element => {
  const a = 5;
  return element === a;
});

console.log(found);
> 5
profile
01210210번째 개발봇

0개의 댓글