1

Possible Duplicate:
Is a closure for dereferencing variables useful?

I've come across an information that because of the way that variable look up works in JavaScript i can gain a performance increase in some situations if i copy the variable i'd otherwise have to look up in a scope chain to a local variable for further access. Are there any general guidelines for this? Creating variables costs too. Is there a way to benchmark access times?

I'm not this paranoid about performance, but i like to stay aware of these things.

Community
  • 1
  • 1
dreta
  • 1,016
  • 3
  • 13
  • 22
  • Typically storing a reference/copy results in a performance gain over long lookup paths, although recent browsers have been working on many under the cover optimizations. For benchmarking you can check out : http://benchmarkjs.com/ – lorefnon Oct 27 '12 at 19:58
  • Well i at least hope this question can help people find the duplicate, because i'd never figure to search for that. – dreta Oct 27 '12 at 20:21

0 Answers0