3 ms·
I'd love to stop using 'new' and embrace a more basic, less side-effect-laden and ultimately more flexible way of creating and returning objects in Javascript,
by CmdrKrool 12y ago
I'd love to stop using 'new' and embrace a more basic, less side-effect-laden and ultimately more flexible way of creating and returning objects in Javascript, such as Object.create(), object literal plus setting __proto__, or whatever. Unfortunately, all of these methods are still massively slower than 'new' - like, three to thirty times slower. (Sixty times, even, if you're on Safari!)
http://jsperf.com/object-create-vs-crockford-vs-jorge-vs-constructor/58 http://jsperf.com/object-create-vs-crockford-vs-jorge-vs-con...
Since he mentioned HTML5 games and trying to improve perfomance by avoiding the garbage collector, well, the above benchmarks are not the kind of thing you would want to compromise on either.