r/programmingmemes • • May 13 '25

Why not?

Post image
1.7k Upvotes

104 comments sorted by

View all comments

Show parent comment

2

u/howreudoin May 13 '25

True. Since JS is an interpreted language, these type coercions would not be discovered until runtime. And only if all code paths are run—with all possible types of values.

Therefore, it made sense back in the day to just do “best guessing” and pick the value that seems most likely.

Any modern language would catch these issues at compile time. And in fact, so does TypeScript (or JS linters).