Monday, 26 August 2013

Should I use `new` when calling functions/constructors like `RegExp`, `Array`, ...?

Should I use `new` when calling functions/constructors like `RegExp`,
`Array`, ...?

I am talking about the functions that return the same object whether or
not called as constructor.
In terms of performance, should I use
new RegExp(rg, flags);
new Array(1000);
new Object(whatever);
...
or
RegExp(rg, flags);
Array(1000);
Object(whatever);
`...`
?
Edit: I was wrong, it matters if I use Object() or new Object()

No comments:

Post a Comment