5 ms·
> the biggest one is probably performance, `new Foo` will always outperform `Object.create(FooProto)`. He's right, `new` is more than 10x faster in Chrome and
by swartkrans 12y ago
> the biggest one is probably performance, `new Foo` will always outperform `Object.create(FooProto)`.
He's right, `new` is more than 10x faster in Chrome and Firefox for me at least:
http://jsperf.com/create-new http://jsperf.com/create-new
Why would it `always outperform` though? Seems like an implementation detail. Object.create should be faster since it doesn't run a constructor.
- phpnode 12y agoThe ever-wonderful Vyacheslav Egorov has a nice article on this: http://mrale.ph/notes/constructor-vs-objectcreate.html http://mrale.ph/notes/constructor-vs-objectcreate.html
- drinchev 12y agoI bet this is because most of JS compilers are optimized in lower level for certain "popular" tasks, developers use to do.