Great succinct article, Mikhail, thank you for writing it.
Question about your .filter example.
You say that using .filter will loop through everything and create another array that contains the result set.
Then, in the forloop example, you are creating a separate array in any case (const result: User[] = []).
As I see it your forloop approach should avoid creating another array - right? What would the approach be to not create a result set array?
In the past I have avoided creating a duplicate by slicing the unmatched value out of the original array. Would that work?
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
Great succinct article, Mikhail, thank you for writing it.
Question about your .filter example.
You say that using .filter will loop through everything and create another array that contains the result set.
Then, in the forloop example, you are creating a separate array in any case (const result: User[] = []).
As I see it your forloop approach should avoid creating another array - right? What would the approach be to not create a result set array?
In the past I have avoided creating a duplicate by slicing the unmatched value out of the original array. Would that work?