191201 어제의 충격 포인트 indexOf
TILindexOf 가 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
저런 방법으로도 찾을 수 있다는 것도 알아두자~
'TIL' 카테고리의 다른 글
javascript 화살표함수 특징 6 _191202 (0) | 2019.12.02 |
---|---|
딥카피 만드는 함수 (0) | 2019.12.02 |
TIL _ node.js & express & mongoDB (0) | 2019.12.01 |
20191128 목 - >>충격<< setInterval return/ react key/ slice.call/ bindFunc.name/ Argument this (0) | 2019.11.28 |
책)러닝 자바스크립트 - weakMap 사용, for of 사용 (0) | 2019.11.27 |