Ranter
Join devRant
Do all the things like
++ or -- rants, post your own rants, comment on others' rants and build your customized dev avatar
Sign Up
Pipeless API
From the creators of devRant, Pipeless lets you power real-time personalized recommendations and activity feeds using a simple API
Learn More
Comments
-
Wait, is this how it works? I’d think that it would be 15 + "6" = "156" because the + operators should be evaluated left to right.
But then again, it’s JS, the teletubby of "programming languages". So, not really surprised. -
Ah, type coercion at its finest.
@Lensflare indeed in this sense, JavaScript is the Teletubby of programming languages 😂 -
kamen69803yIf you write JavaScript like that, I don't want to be your friend.
On a serious note, of course it's silly that it allows stuff like this, but then again the language was written in one week; moreover if they somehow change it to disallow things like this, it would break like 80% of the sites that are live right now. -
@kamen of course nobody can expect that to change because it would break compatibility. But it’s nice to see people admitting that it is a horrible design rather than trying to justify it as something that makes JS awesome.
And saying "It’s only bad because you don’t understand it 🤪". -
@Lensflare doesn't actually matter, and only makes the point better: we are unsure and guessing which of the two stupid unexpected/unwanted/incorrect behaviors will happen =D
1 + 2 + 3 + 4 + 5 + “6”
joke/meme
javascript
string