Makes total sense. '+' is an operator valid with strings and '-' is not. In the first one the 1 is converted to a string. But since - is not a string op, it has to convert "1" into the number 1.
2024-09-02 14:18:20
182
Matisiv :
String, int, float.
2024-11-04 23:41:45
1
ABC :
I mean it makes sense. One is an overloaded function that can work on strings and numbers, one can only work on numbers. So it converts them to match what the priority is
2024-08-31 22:15:11
71
drDBL :
This is why I like JS. It's only for intelligent people 🤷♂️
2024-08-31 19:39:05
47
chimble :
it worng
2024-09-13 06:52:15
1
Changa Husky :
I guess data types are just suggestions.
2024-08-31 20:13:40
22
Olaaf :
string concatenation makes my life much easier
2024-10-20 22:15:03
1
BadGuyStrider :
Aaah yes, concatenation where addition is expected. Left me bamboozled once or twice in college 😂
2024-11-03 15:57:10
1
Nick Hoff :
If you went to a boot camp, I understand why this is confusing 🤣
2024-09-03 17:59:10
1
😫 :
Don’t misuse types and JS is an amazing lang.
2024-08-30 18:52:47
4
Fabio Gaming :
Just use typescript
2024-10-13 19:55:28
1
Cute Videos :
What about 1-“-1”+1 ?
2024-09-01 09:26:34
4
Yousef يوسف :
Wait i just started js what is that fr how
The first is number the second is letter the first one is ok the second is weird how did that happen?
2024-09-12 16:10:32
1
ArtRoo :
Can U explain ?
2024-10-08 18:50:50
1
DungeonGrid :
Makes total sense. But this demonstrates that you should not write this kind of code.
2024-08-31 07:29:49
2
Saviez-vous? :
+ converts to string - converts to number?
2024-08-29 13:25:22
10
fuzybritches :
this was taught in the books I read. they definitely explain better then I could.
2024-08-31 23:13:57
1
springer1070 :
I've used JavaScript professionally for over 5 years and have never encountered this problem lol.
2024-08-31 17:33:52
12
toopham :
what do you expect when you add a number with a string ? 😂
2024-08-31 23:02:46
2
CAPY HTTP :
this is magic 😂😂
2024-10-07 09:41:03
1
Tcr :
lua have this too 😭😭👍👌
2024-10-16 11:17:46
2
Enormous Deer :
This is what happens when you give a duck typing capabilities.
2024-09-01 20:33:26
1
Poiuytrewq123 :
Man try overwriting any toString method that’s fun
2024-10-12 19:14:02
1
To see more videos from user @techbrosmemes, please go to the Tikwm
homepage.