What’s the differences, pros, or cons of
var obj = {};
VS
var obj = new Object();
All I know is that the second example takes longer. Is there any real benefit?
** EDIT **
function loop() {
var start = (new Date()).getTime();
for(var i = 0; i < 1000000; ++i) {
//var b = {}; // takes ~548ms on my machine
var b = new Object(); // takes ~287ms on my machine
}
trace((new Date()).getTime() - start);
setTimeout(loop, 1);
}
loop();
If you switch between var b = {}; and var b = new Object(); You’ll see the performance differences. They are opposite from my recollection and what I mentioned in the question.
As far as I’m aware, they are equivalent. By “the second example takes longer”, I assume you mean only in time to type the statement, and maybe a probably immeasurable amount of time to evaluate – but the execution time should be equivalent.