4 ms·
I have never, ever come across a scenario where assigning to the object instead of the prototype has made any meaningful impact on performance. The only scenar
by doomslice 14y ago
I have never, ever come across a scenario where assigning to the object instead of the prototype has made any meaningful impact on performance.
The only scenario I can even think of where it would maybe possibly matter would be a tight loop where you are doing little else except just accessing properties.
- ratbeard 14y agoI can imagine it having an impact on a graphics app where a `Point` class might be instantiated thousands of times, or even if the Backbone.Model constructor were hundreds of lines long to attach all the public methods. It would be weird to me to have to spend a few seconds of thought on a per-object basis to think how I should structure the code based on how often I think it will be instantiated. But yes, I also have not been bitten by this. Its just something I've read about how the v8 engine works (and makes sense intuitively). I agree you shouldn't base coding style decisions soley on hearing one way is faster, but I think its a minor point and worth noting. Edit: a link! https://news.ycombinator.com/item?id=2991904 https://news.ycombinator.com/item?id=2991904