Coding Test

Programmers ์™„์ „ํƒ์ƒ‰: ๋ชจ์˜๊ณ ์‚ฌ

Deviloper๐Ÿ˜ˆ 2021. 8. 15. 10:24

โœ… ์ƒˆ๋กœ ๋ฐฐ์šด ์ 

filter ํ•จ์ˆ˜๋ฅผ ์‚ฌ์šฉํ•  ๋•Œ ์„ธ ๊ฐ€์ง€์˜ argument๋ฅผ ๋ฐ›์„ ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.

1. ๊ธฐ๋ณธ์ ์ธ element

2. ํ˜„์žฌ ์‚ฌ์šฉ๋˜๊ณ  ์žˆ๋Š” element์˜ ์ธ๋ฑ์Šค ๋ฒˆํ˜ธ

3. filter ํ•จ์ˆ˜์— ์‚ฌ์šฉ๋˜๋Š” ๋ฐฐ์—ด

 

 

element

The current element being processed in the array.

 

index (Optional)

The index of the current element being processed in the array.

 

array (Optional)

The array filter was called upon.

 

์ฐธ๊ณ 

Array.prototype.filter()

 

Array.prototype.filter() - JavaScript | MDN

The filter() method creates a new array with all elements that pass the test implemented by the provided function.

developer.mozilla.org