MAIN FEEDS
Do you want to continue?
https://www.reddit.com/r/ProgrammerHumor/comments/1bjjkm6/arejsdevsactuallysane/kvurnby/
r/ProgrammerHumor • u/jarulsamy • Mar 20 '24
554 comments sorted by
View all comments
Show parent comment
1
No, it's not reasonable behavior. It's in line with how JS works much of the time, but that doesn't make it reasonable behavior to begin with.
Here are some examples that rightfully don't work in JS:
Symbols fail despite having both valueOf and toString:
new RegExp(Symbol()) // Uncaught TypeError: Cannot convert a Symbol value to a string
Functions fail despite having both valueOf and toString:
BigInt(() => {}) // Uncaught SyntaxError: Cannot convert () => {} to a BigInt
1 u/_xiphiaz Mar 21 '24 Interesting, though symbols are not objects which probably explains that. 2 u/SoInsightful Mar 21 '24 We can probably find engine-level explanations for all of these cases if we dig deep. I'm just saying that they're not all "reasonable" ❤️
Interesting, though symbols are not objects which probably explains that.
2 u/SoInsightful Mar 21 '24 We can probably find engine-level explanations for all of these cases if we dig deep. I'm just saying that they're not all "reasonable" ❤️
2
We can probably find engine-level explanations for all of these cases if we dig deep. I'm just saying that they're not all "reasonable" ❤️
View all comments
Show parent comment
1
u/SoInsightful Mar 21 '24
No, it's not reasonable behavior. It's in line with how JS works much of the time, but that doesn't make it reasonable behavior to begin with.
Here are some examples that rightfully don't work in JS:
Symbols fail despite having both valueOf and toString:
Functions fail despite having both valueOf and toString: