Created
October 18, 2018 21:32
-
-
Save cevek/23ec40ce0d34609be0ea4aec7b1ac369 to your computer and use it in GitHub Desktop.
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
function abc(obj, prop) { | |
for (let j = 0; j < 1e7; j++) { | |
var x = obj[prop]; | |
} | |
return x; | |
} | |
function abc2(obj) { | |
for (let j = 0; j < 1e7; j++) { | |
var x = obj.b; | |
} | |
return x; | |
} | |
var obj = {a: 1, b: 2, c: 3} | |
abc(obj, 'a'); | |
abc(obj, 'b'); | |
abc(obj, 'c'); | |
console.time('perf'); | |
abc(obj, 'b'); | |
console.timeEnd('perf'); | |
console.time('perf'); | |
abc2(obj); | |
console.timeEnd('perf'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment