r/ProgrammerHumor • • Jun 21 '18

Thanks Brendan for giving us the Javascript

Post image
3.1k Upvotes

302 comments sorted by

View all comments

Show parent comment

12

u/xIcarus227 Jun 22 '18

I agree that some of these have no real purpose IRL but I also think you underestimate the amount of bugs some of these cause in the real world. A notable mention is adding vs subtracting an integer with a string. Especially since everything tends to be a string in the DOM.

2

u/[deleted] Jun 22 '18

Sure, it doesn't complain if you forget to parseInt or parseFloat, but that's like the spectator asking Charles Babbage: "If you feed it the wrong input will it give you the correct output?"

Just... figure out what you're doing. Escape your inputs, parse your inputs, validate your inputs, etc. It's a basic requirement for everything web.

5

u/xIcarus227 Jun 22 '18

I certainly agree with what you're saying, writing PHP and JS daily for a few years taught me those lessons the hard way. I hit my head countless times against quirky behaviour.
I admit it's second nature now, but I just think it's a bit dangerous when such matters are promoted as 'normal', as a matter of just knowing the language deeply.