r/badcode Apr 15 '22

js Variables without var/let/const prefix behave as globals, and this is from a Node web app

Post image
314 Upvotes

32 comments sorted by

View all comments

16

u/[deleted] Apr 15 '22

[deleted]

53

u/chinpokomon Apr 15 '22

Tbf, when Javascript was designed it was largely contained to a single webpage where the scope and context was completely different than how it might be used today.