set 썸네일형 리스트형 [JavaScript] 배열 내 특정 값 찾기 - find(), includes() ,Set 객체의 has() find() 메서드를 통해 배열 내 특정 값 찾기 const array = [1, 2, 3, 4]; array.find(data => data === 1);// 1 array.find(data => data === 3);// 3 array.find(data => data === 5);// undefinded 주어진 조건을 만족하는 값을 출력한다. 주어진 조건을 만족하는 값이 존재하지 않을 경우 undefinded를 리턴한다. includes() 메서드를 통해 배열 내 특정 값 찾기 const array = [1, 2, 3, 4]; array.includes(1)// true array.includes(3)// true array.includes(5)// false 값이 존재하는 경우 true를 리턴한다... 더보기 [JavaScript] Set 객체를 통해 배열 중복 제거 const array = new Set([1, 2, 3, 3, 2, 1]); console.log(array) // {1, 2, 3} 더보기 이전 1 다음