Created
December 8, 2012 02:12
-
-
Save tricknotes/4238204 to your computer and use it in GitHub Desktop.
Performance check about deleting property null assignment
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var now; | |
var obj, i; | |
var count = 10000000; | |
var key = 'key'; | |
obj = {}; | |
now = Date.now(); | |
for (i = 0; i < count; i++) { | |
obj[key] = 1; | |
obj[key] = null; | |
} | |
console.log('null assignment(`obj[key] = null`):\n %d ms', Date.now() - now); | |
obj = {}; | |
now = Date.now(); | |
for (i = 0; i < count; i++) { | |
obj[key] = 1; | |
delete obj[key]; | |
} | |
console.log('deleting property(`delete obj[key]`):\n %d ms', Date.now() - now); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment