DEV Community


Discussion on: Write a Custom JavaScript Filter Function that is 60% faster than Array.filter

functional_js profile image
Functional Javascript Author

Honestly speaking Aleksandr, I would not go down that path.
It's considered an antipattern to touch the prototype object.

One big danger is that this is not universal. You would always have to call this code first if you wanted to use the function. That would create massive spaghetti and bug vulnerabilities in your code.
Nevermind having dozens of user-defined functions tacked on to the prototype.
You would never know what's where.

I imagine you don't use ESLint. Unless you've turned off the "never modify the prototype" rule.

Thanks for you input though, it's an important point to highlight

Javascript Prototype Antipattern

Here is a list of JavaScript constructs I do not use...

Forem Open with the Forem app