Why Does '5' + 5 Become '55'? JavaScript Types Explained
The Logic Lab
0:00 / 0:00
Why Does '5' + 5 Become '55'? JavaScript Types Explained
8 просмотров · 5 часов назад
The Logic Lab
1 подписчик
8 просмотров · 5 часов назад
Why does JavaScript turn `'5' + 5` into `'55'`, while `'5' - 2` becomes `3`? The answer is data types: the same symbol can behave differently depending on whether a value is a number or a string.
This visual lesson covers numbers, strings, booleans, `null`, `undefined`, `typeof`, floating-point decimals, and JavaScript’s automatic type conversion.
*Try it:* Predict the result of a few JavaScript expressions before running them in the console.
Subscribe for visual lessons on JavaScript and computer science.
#JavaScript #DataTypes #ProgrammingForBeginners