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
-
Alfufu518y@RazorSh4rk an error of some sort is what I would expect.
Edit:
Forget this was javascript I take my words back I don't expect anything -
I keep my politics and my honest opinion of JavaScript to myself. I don't want people I like getting upset.
-
Leya17718yThe "+" operator on strings is the concatenate operator that will connect two strings (or in this case string and int). There is no "-" operator for string so I guess it makes sense that JavaScript assumes it's a arithmetic operation
-
Lukas18698yIn some languages, you can deduct 2 strings. You then get the Levenshtein distance between the 2 strings: the smallest amount of single letter operations to transform string a to string b @ElCapitan
-
Yeah, Javascript sucks. People do amazing things with it indeed, but it still sucks.
-
I won't be surprised the day they come up with a "you know what I mean" operator, for operations like
“5” ? 1 = “Six" -
xios16438yI do Java. I try to do JavaScript thinking I got this and it makes me want to throw My monitor out of the window, stick the keyboard Into the ass of the neighbor, use mouse as a flail and kill everyone and use the laptop as a campfire. I still try. I like to see the world burn.
Then to stabilize my mind I do some Python.
=D -
Grumpy28828yPrecisely the sort of thing to expect from a dynamic language. I vastly prefer static type systems, especially Haskell's.
-
xios16438y@DServy Never really looked at Apex. Quick glimpse looks like an iteration of Java with a .. WTF is that:
Use the following syntax for creating a list:
List<Integer> My_List = new List<Integer>();
List <datatype> list_name
[= new List<datatype>();] |
[=new List<datatype>{value [, value2. . .]};] |;
I feel your pain -
MunzMan3058yXD Only a JS dev would get it.
second:
a string "plus" a number should always be a string . comparing not equal values and/or types should always result in false. in parallel universe that's called logic .
first: Hi , thanks for the post. -
Grumpy28828y@MunzMan No, it's not called logic. It's called type coercion. Some languages call it implicit type conversion.
Operators AND, XOR, NOT and OR is called logic. -
I could be wrong but the simple explanation that come to my mind is : the substract operator has no implementation for string type, so it handle both as number. The + operator has an implementation for string, so it override the sum behavior.
-
MunzMan3058y@SpencerBeige the order of the bullet points I wrote is incorrect, I was making fun of JS async, that's what i meant by "Just JS dev would understand"
JavaScript:
> "5" - 2
3
> "5" + 2
"52"
Enjoy coercion.
undefined