TIL
191201 어제의 충격 포인트 indexOf
은:D
2019. 12. 2. 15:33
indexOf 가 string 대상인줄 알았는데
Array 에도 적용이 가능했다..!
(es2015)
https://developer.mozilla.org/ko/docs/Web/JavaScript/Reference/Global_Objects/Array/indexOf
Array.prototype.indexOf()
indexOf() 메서드는 배열에서 지정된 요소를 찾을 수있는 첫 번째 인덱스를 반환하고 존재하지 않으면 -1을 반환합니다.
developer.mozilla.org
(es2016)
이제까진 includes를 써왔는데!!!
https://developer.mozilla.org/ko/docs/Web/JavaScript/Reference/Global_Objects/Array/includes
Array.prototype.includes()
includes() 메서드는 배열이 특정 요소를 포함하고 있는지 판별합니다.
developer.mozilla.org
저런 방법으로도 찾을 수 있다는 것도 알아두자~