Wednesday, May 23, 2012

Why can't one set an alias to a document.getElementById()?

My code would be more efficient if I could write

var min = window.document.getElementById;

and then call document.getElementById() using min().

I'm not trying to write minified code but in this particular case I can reduce scope lookup and shorten some lines.

Perhaps I'm using the wrong syntax?

No comments:

Post a Comment