alhimikpaulo
New Member
I have benchmarked two methods:Access array items\[code\]var object = [10, 15, 20];var x = object[0];var y = object[1];var z = object[2];\[/code\]and Access object properties\[code\]var object = { x: 10, y: 15, z: 20};var x = object.x;var y = object.y;var z = object.z;\[/code\]I expected the access to array items to be much faster, since there's no property name resolution involved.However, to my surprise, accessing object properties was roughly 30% faster across all browsers.
[URL to benchmark]That benchmark results made me confused. For what reason should the former method be so much slower than the latter?