2 ms·
Is that really optimized/optimal? I'd be curious to see jsperf benchmarks of this method of constructor vs the straighforward approach. The JS VMs tend to kind
by cromwellian 12y ago
Is that really optimized/optimal? I'd be curious to see jsperf benchmarks of this method of constructor vs the straighforward approach.
The JS VMs tend to kind of finnicky and optimized towards certain types of idiomatic Javascript and it's my guess that the further off the common path you stray, the more likely you are to hit performance gotchas.
Your best bet is to transpile code that looks much like the benchmark suites they run. :)
- drinchev 12y agoI also agree with what you are saying. JS in terms of usage is so big that I guess developers behind JS compilers will have to optimize for "the most popular way of solving that problem". In any case, why I mentioned preprocessors is that there is a lot of history behind every feature. As of this there are a couple of github issues [1] that explain why this approach has been used. For the performance. Seems that "new" is way faster. [2] [1] : https://github.com/jashkenas/coffeescript/issues/912 https://github.com/jashkenas/coffeescript/issues/912 [2] : https://jsperf.com/obj-create-vs-new/4 https://jsperf.com/obj-create-vs-new/4
- deleted 12y ago[deleted]