DEV Community

Discussion on: Let's create our own filter method in JS

Collapse
 
sektor001 profile image
Sektor001

Why do you have (this[i], i, this) in the if statement? dont you only need this[i]?

Collapse
 
santoshah profile image
Santosh

I was thinking same. In this context we would need only this[i] but we are trying to create a generic function that does more than just a filter. By passing index and entire array we can also get specific position element. This is what I have understand.

Collapse
 
machy44 profile image
machy44

You were right. Sorry I didnt see your comments before