- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
// CODE 1
var s = new Date().getTime();
var o = Object.create(null);
o.delta = 1;
(function () {
var counter = 0, x = 1000 * 1000 * 1000;
for(var i = 0; i < x; i++) { counter += o.delta; }
console.log('Final result: ' + counter);
}());
console.log('Total time: ' + (new Date().getTime() - s) + ' ms');
// CODE 2
var o2 = Object.create({});
o2.delta = 1;
(function () {
var counter = 0, x = 1000 * 1000 * 1000;
for(var i = 0; i < x; i++) { counter += o2.delta; }
console.log('Final result: ' + counter);
}());
console.log('Total time: ' + (new Date().getTime() - s2) + ' ms');