3 ms·
Adding methods to prototypes is effectively free. The only time mutating a builtin prototype has negative consequences is when you replace a builtin function w
by cogman10 4y ago
Adding methods to prototypes is effectively free. The only time mutating a builtin prototype has negative consequences is when you replace a builtin function with your own thing. All javascript engines (that I'm aware of) JIT at the method level so there's not really a performance impact modifying a prototype.
- strbean 4y agoAh, I think this is what I was thinking of: https://developer.mozilla.org/en-US/docs/Web/JavaScript/The_performance_hazards_of_prototype_mutation https://developer.mozilla.org/en-US/docs/Web/JavaScript/The_... It seems this only pertains specifically to overwriting the __proto__ of an existing object (the is the prototype of other things).