#Why is it that in JavaScript 2 + 2 = 22;, but 2 - 2 = 0;?
1 messages · Page 1 of 1 (latest)
string concatenation, if the two values are a string
Wait, so in JavaScript, integers are strings?
if not strictly typed they can be
"2" + 2 = 22 for instance
but 2 + 2 = 4
only for addition though, as the plus char is used for string concatenation, a minus not
yeah use typescript instead
I don't like Microsoft lol
rip C#
oof
Don't worry, I am very young, and I have enough time to learn pointers in C++
Though, I am currently learning regular C
I will have a blast when learning C++
regular C is just pure pain 
C++ is much better there, but still shit
regular C is just pure pain :CattoCry:
I like it
oh damn, never heard anyone say that. Even at my university people used to hate C
I haven't learned all of it yet, I can currently make very basic calculators, but I really like C
I am not a boomer or anything (actually the opposite), but so far I like the programming language
its good to have C as a skill though, theres that
💀
💀
Why is 2 + 2 = 22 in JavaScript? - @stoic silo
Why is 2 + 2 = 22 in JavaScript?
2 + 2 = 22 in JavaScript is a result of a type coercion. JavaScript is a loosely typed language, which means that it will automatically convert different data types when necessary in order to complete an operation. In this case, when adding the number 2 and the number 2 together, JavaScript will convert the numbers to strings and concatenate them, resulting in the string "22".
js is so silly
"JavaScript is such an awful language" Stack overflow survey: Cope