r/ProgrammerHumor • • Feb 07 '19

other Spotted on GitHub 🤓

Post image
57.0k Upvotes

934 comments sorted by

View all comments

4

u/ProgramTheWorld Feb 07 '19

document.getElementsByTagName("BODY")[0]

As a web dev, reading this hurts.

1

u/pomlife Feb 07 '19

Also using var, and using snake case in JS.

-1

u/Bag06a Feb 07 '19

It's "pure" JavaScript.....it shouldn't really make you cringe. It can be essential to know it

7

u/ProgramTheWorld Feb 07 '19

It is cringe because that will cause an extra function call (that traverses the entire DOM!) and create an unnecessary NodeList object. Rather than doing what they did, what they should do is simply document.body which is both easier to understand and more efficient.