본문 바로가기

FrontEnd/Javascript

[Javascript] Array.prototype.find(callback[, thisArg])

반응형

return

  1. The value of the first element in the array that satisfies the provided testing function. Otherwise, undefined is returned.(판별 함수를 만족하는 첫번째 값, 없으면 undefined를 리턴)

example

let arr = [1,2,3]

let find = arr.find(function(a){
    return a === 1
}

console.log(find) //1
//Arrow Function
let arr = [1,2,3]

let find = arr.find(a => a===1)

console.log(find) //1

*참고 : https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global\_Objects/Array/find

반응형