336
parseInt(5) (lemmy.ml)
you are viewing a single comment's thread
view the rest of the comments
[-] danda@lemmy.zip 87 points 12 hours ago

It's because parseInt is expecting a string, so the decimal gets converted to a string, and 0.0000005.toString() returns 5e-7.

[-] KindaABigDyl@programming.dev 35 points 12 hours ago

Common Dynamic Typing L

[-] spizzat2@lemm.ee 22 points 11 hours ago* (last edited 10 hours ago)

And to further expand on that, if you do pass in a ~~sting~~ string, it handles it correctly.

> parseInt('0.0000005')

0
[-] SpaceNoodle@lemmy.world 13 points 10 hours ago

What if I pass in a Sterwart Copeland?

[-] xtools@programming.dev 2 points 4 hours ago

or a Honda civic

[-] spizzat2@lemm.ee 7 points 10 hours ago

๐Ÿ˜† I'll be watching you...

this post was submitted on 05 May 2025
336 points (98.6% liked)

Programmer Humor

23025 readers
1452 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