re: Do's and Don'ts for Javascript Newbies VIEW POST

FULL DISCUSSION
 

I'm a near-intermediate JS developer and was surprised to learn that access by element id is the fastest way. Thanks for posting this! 😄

 

DOM elements are also global when accessed by ID. e.g. window['my_element_id'] or my_element_id #oldschoolweb

 

Here's some more web anecdotes

Because it's seems not standard :/ but you can easely recreate this idea:

document.querySelectorAll("[id]").forEach(el => window[el.id] = el);

 
code of conduct - report abuse