I am seeing some odd behavior in a jsperf test. Here is the setup:
var pro={};
pro._x=3;
var q=Object.create(pro);
q.x=3;
q.z={};
q.z.x=3;
Then I simply lookup each of the properties q.x
, q._x
, and q.z.x
.
The single lookup q.x
is faster than the prototype lookup q._x
as expected. But the double lookup q.z.x
is the fastest. I expected q.z.x
to be the slowest, especially when compared to q.x
.
q.z.x
is even faster than q.z
. What is going on here?