> Caching a property lookup is usually not really worth it*. Best > consideration for doing it anyways is clean code. But don't do it for speed.
In terms of data access, object property lookup *is* slower than using a local variable. Peter's right that for the most part it doesn't matter and that clean code is the important thing, but if you have an object property that is getting hit within a loop and has the potential of being used a lot, using an alias will be better for performance. I guess the rule of thumb is to write for clarity, and only worry about doing micro-optimizations when you notice performance issues. Nicholas Zakas from Yahoo discusses data access in a presentation called Speeding Up Your JavaScript: http://googlecode.blogspot.com/2009/06/nicholas-c-zakas-speed-up-your.html -- To view archived discussions from the original JSMentors Mailman list: http://www.mail-archive.com/jsmentors@jsmentors.com/ To search via a non-Google archive, visit here: http://www.mail-archive.com/jsmentors@googlegroups.com/ To unsubscribe from this group, send email to jsmentors+unsubscr...@googlegroups.com