Hacker News new | ask | show | jobs
by dkordik 4592 days ago
TIL: DOM elements with IDs are automatically available as properties of window. (ball, paddle, etc.)
3 comments

A couple of findings:

- This stackoverflow answer has a good back story on this: (TLDR, it's not standard... yet) http://stackoverflow.com/a/3434388/1339100

but it is in this HTML 5.1 draft: http://www.w3.org/html/wg/drafts/html/master/browsers.html#n...

- It's slower than document.getElementById, somehow: http://jsperf.com/implicit-dom-element-variables

Me too. Anyone know what browser support is like?
I was surprised too. I thought you would have to explicitly select it with getElementById()