JS is a prototype-based language which means that if we create an array variable, it's prototype is Array.prototype. Every array inherits the metho...
For further actions, you may consider blocking this person and/or reporting abuse
Why do you have (this[i], i, this) in the if statement? dont you only need this[i]?
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.
You were right. Sorry I didnt see your comments before
Cool! It's funny, I was just inspired to write my first post about a 'lazy' version of 'map' and 'filter' in JavaScript!
That's great! :) It seems very interesting. I will take a look on your post.
Thanks... quite easy to understand.
if (fun(this[i], i, this)) filtered.push(this[i]);
In this line why are there no curly braces around filtered.push(this[i]); ?
like this:
if(fun(this[i], i, this)) {
filtered.push(this[i]);
}
syntax is not important here. I believe that today I would write it with curly braces.