this post was submitted on 05 May 2025
383 points (98.7% liked)

Programmer Humor

23011 readers
1638 users here now

Welcome to Programmer Humor!

This is a place where you can post jokes, memes, humor, etc. related to programming!

For sharing awful code theres also Programming Horror.

Rules

founded 2 years ago
MODERATORS
 
you are viewing a single comment's thread
view the rest of the comments
[–] FMT99@lemmy.world 49 points 17 hours ago (22 children)

Another classic javascript wat

[–] victorz@lemmy.world 3 points 15 hours ago (21 children)

Classic people who don't know how to code wat. Passing a number in place of a string argument because they don't know what they're doing.

[–] jjjalljs@ttrpg.network 33 points 15 hours ago (2 children)

Javascript could throw an error to alert you that the input is supposed to be a string, like most languages would do.

[–] victorz@lemmy.world -3 points 12 hours ago* (last edited 12 hours ago) (1 children)

But you're calling a function specifically made for passing a string to an int... 😆 There's gotta be some common sense somewhere here, guys.

Still, it's a very good point. JS should do this.

I would suspect one reason it doesn't do this is to be backwards compatible.

[–] listless@lemmy.cringecollective.io 1 points 3 hours ago (1 children)

And god fucking forbid that common sense be in the language. Who the fuck needs a language with common sense, amirite?

[–] heavy@sh.itjust.works -3 points 14 hours ago (3 children)

Theoretically, Javascript is an untyped language, so there aren't supposed to really be static types. Giving type errors in this situation would be against design.

[–] jjjalljs@ttrpg.network 25 points 14 hours ago (1 children)

Maybe the design is bad, then.

[–] heavy@sh.itjust.works 4 points 13 hours ago

Lol you'll get no argument from me. It's not my favorite language.

[–] bleistift2@sopuli.xyz 4 points 11 hours ago (1 children)

JavaScript has types and it does have type errors, for instance

> null.foo
Uncaught TypeError: null has no properties

Please stop spouting nonsense on issues you know nothing about.

[–] heavy@sh.itjust.works -2 points 10 hours ago (1 children)

Dynamic types aren't static types my man. I think you got some learning to do.

[–] victorz@lemmy.world 2 points 1 hour ago

You did say untyped though.

[–] zqwzzle@lemmy.ca -1 points 12 hours ago

Theoretically, Javascript is an untyped language…

Function only handles string arguments correctly. Wat.

load more comments (18 replies)
load more comments (18 replies)