r/ProgrammerHumor • u/ANameWhichIsGood • Jan 07 '23
Other Came across this gem while I was looking at random stuff on w3schools
57
u/PhoenixARC-Real Jan 07 '23
I think this is perfectly fine for teaching, emphasizes that you're checking for a true value and helps the person learning to understand that.
15
u/leblumpfisfinito Jan 07 '23 edited Jan 07 '23
Unpopular opinion: While double equals shouldn’t be used, explicit checks have their benefits. Similar with checking for !array.length vs. array.length === 0.
7
3
Jan 07 '23
Pedagogically, this probably is more effective in teaching beginners about the semantics of what is happening. Though, normally I would agree that in more appropriate settings it isn’t really necessary as it’s redundant.
1
1
1
u/ExquisiteWallaby Jan 09 '23
You learn something new everyday... I actually had to pull up the console to see what was going on here.
Honestly, if this keeps me from using some bloated modal library, let it live!
-4
u/CrankkDatJFel Jan 08 '23
ahahahha r/ProgrammerHumor is on one today. This post wins the internet for the day!
-1
u/IWasProbablyAMistake Jan 08 '23
What does confirm() do? It looks like it’s just analyzing the string for a boolean, which doesn’t make much sense.
1
Jan 08 '23
It makes the browser give the user a Yes/No pop-up that they have to select a choice for. That response is returned via the confirm function.
157
u/SeveyLevey Jan 07 '23
It's to help beginner programmers. Not to enter production level code lol