๐Ÿ‘ฉ‍๐Ÿ’ป๊ฐœ๋ฐœ_TIL/์ž๋ฃŒ

[์ž๋ฐ”์Šคํฌ๋ฆฝํŠธ] ๋ฐฐ์—ด์˜ ํŠน์ • ๊ฐ’์„ ์ฐพ๋Š” ๋ฉ”์„œ๋“œ ์ •๋ฆฌ ๋ชจ์Œ

Daisy.lee 2022. 1. 25. 11:02

1. find vs findIndex vs indexOf

https://bit.ly/3Awj1RK

 

๋ฐฐ์—ด ๋‚ด์žฅํ•จ์ˆ˜ (indexOf / findIndex / find)

indexOf ๋Š” ๋ฐฐ์—ด์—์„œ ์›ํ•˜๋Š” ํŠน์ • ํ•ญ๋ชฉ์ด ๋ฐฐ์—ด์˜ ๋ช‡๋ฒˆ์งธ ์›์†Œ์ธ์ง€ ์ฐพ์•„ index๋ฅผ ๋ฆฌํ„ดํ•ด์ฃผ๋Š” ํ•จ์ˆ˜. (๋งŒ์•ฝ์— ๋ชป์ฐพ์œผ๋ฉด -1 ๋ฆฌํ„ด)๋งŒ์•ฝ ์œ„์—์„œ ์ฒ˜๋Ÿผ ์ฐพ๊ณ ์žํ•˜๋Š” ๊ฒƒ์ด boolean, ์ •์ˆ˜, ๋ฌธ์ž์—ด... ์ด๋ฉด ์œ„์™€ ๊ฐ™์ด

velog.io

find ๊ฐœ๋…

findIndex ๊ฐœ๋…

indexOf ๊ฐœ๋…