728x90

✨ Array에 내가 입력한 값(String or Number etc.)이 포함되어 있는지 확인할 때 사용하는 helper method

(e.g., strArr.includes('a')) 왼쪽처럼 strArr이라는 Array에 'a'가 있다면 true, 없다면 false를 return.
Vowels(모음 찾기) Algorithm에서 유용하게 사용하였다.

 

💻Example Code

const strArr = [ 'a', 'b', 'c' ];

console.log( strArr.includes('a') );

실행 결과( 'a'가 포함되어있기 때문에 true 출력 )

😋 Vowels(모음 찾기) Algorithm을 풀 때, 주어진 String에서 모음(a, e, i, o, u)이 몇 개인지 찾을 때 매우 유용하다.
더 활용된 내용은 Algorithm 카테고리의 Vowels(모음 찾기) Algorithm을 참고하시면 됩니다. 

👉 자세한 내용은 https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/includes

'JavaScript > Built-in Method etc.' 카테고리의 다른 글

Array.prototype.sort()  (0) 2019.12.28
String.prototype.toLowerCase() & toUpperCase()  (0) 2019.12.28
Array.prototype.every()  (0) 2019.12.24
Array.prototype.reduce()  (0) 2019.12.24
Array.prototype.join()  (0) 2019.12.24

+ Recent posts