I've made a simple object creation benchmark. I know "there are lies, damn lies and benchmarks", however the difference seems huge. Can anyone tell me if I'm doing something wrong. Or if not, how is it possible? I'm new to JS so please don't beat me.
http://jsperf.com/factoryvsconstvsobjectcreate/3
/Edit thanks Andrew Fedoniouk for a little bugfix
The huge difference between the Factory and Constructor tests is due to a series of extra steps performed in the latter.
When a function is invoked as a constructor, its [[Construct]] internal method is invoked, and that's likely the cause of the performance difference. Look at all the steps involved in [[Construct]]: