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
-
@Greggergalactic so when it comes to +, it adds the int to the char... I mean string.
And when it comes to -, it doesn't concatenate... but why? Is there no way to do something like "reverse concatenation" (this is obviously a made up acronym BTW) -
@demiko It doesn't, it will do the same if string is first. I suppose designers assumed that it is more common to concat string and other types without casting them, than it is to do numerical operations on non numerical types. From my own experience I find this to be true.
They could have of course do some fancy checks to see if all values will evaluate to numerical types and choose to do numerical operation instead by I personally prefer that it is just "If one value is string and you are using string operator then it will be always string operator that is used". -
@Greggergalactic No, that makes sense in normal speaking. THAT IS FUCKED UP IN PROGRAMMING.
-
@Greggergalactic
Idk it was a product of brainstorming. Maybe it doesn't exist... just a thought :)
JavaScript logic.
undefined