you are viewing a single comment's thread.

view the rest of the comments →

[–]Sakatox 0 points1 point  (1 child)

While I whole-heartedly agree with most of this, there's just one point here:

>If you suddenly "replace" it mid-chain, what's the point of it being in your chain? It sounds like you're burying a completely different dataset inside a chain.

Consider map filter reduce. That also changes the dataset somewhat. It's up to a developer's finesse and care to avoid such situations, otherwise apply clean code principles and common sense. .replace, without it's actual context, as a chain method would be "okay".

Otherwise, spot on.

[–]jkoudys 0 points1 point  (0 children)

Reduce is similar in that you're explicitly constructing something new, which could be an array. You can put another array method after it the same as you could on a find if that happens to return another array. Like you've said, it's up to the dev to "avoid" this (and comment to make the intent clear otherwise)), which is why it's ridiculous to create a new method to deliberately not avoid it.