234
parseInt(5) (lemmy.ml)
you are viewing a single comment's thread
view the rest of the comments
[-] jjjalljs@ttrpg.network 22 points 4 hours ago

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 2 points 1 hour ago* (last edited 59 minutes ago)

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.

[-] heavy@sh.itjust.works 0 points 3 hours ago

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 14 points 3 hours ago

Maybe the design is bad, then.

[-] heavy@sh.itjust.works 3 points 2 hours ago

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

[-] zqwzzle@lemmy.ca 0 points 1 hour ago

Theoretically, Javascript is an untyped language…

Function only handles string arguments correctly. Wat.

this post was submitted on 05 May 2025
234 points (99.2% liked)

Programmer Humor

22995 readers
1068 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