Let's say I have a variable nested deeply within a massive object which I re-use quite often:
i = 10000000;
while (i) {
i--;
document.write( bigobject.a.b.c.d.e.f.g.h.i.j.k.l.m.n.o.p );
}
Would it be faster to cache it in a new variable outside of the loop?
v = bigobject.a.b.c.d.e.f.g.h.i.j.k.l.m.n.o.p
and use that cached variable in my loop?
document.write ( v );
For the less visually oriented: Are JavaScript variables cached automatically or does the browser have to search through the larger variable each time it's requested?