JavaScript Identifer Depth Test

The purpose of this page is to determine the performance issues related to scope chain identifier depth in JavaScript. In all browsers, local variables are faster to both read from and write to, however, the performance difference when accessing out-of-scope identifiers varies.

The tests on this page access each variable a set number of times. That is repeated 100 times and the average time is reported. The scope chain depth is augmented by wrapping anonymous, self-executing functions around the code that accesses the variables. As a point of comparison, I also test global identifier resolution to see if there's any performance difference associated with global variables. The tests may take several minutes to fully execute but should not crash the browser.

Back to my site.

Accesses variables times