Using Operators with Different Types
Learn what happens when we try to add, subtract, and divide strings. We'll cover how JavaScript handles 'abc' + 20. Learn what NaN is. We'll also discuss type coercion, a very import concept in JavaScript.
We'll cover the following...
Different Variable Types
We’ve shown these operators being used on numbers only. They can also be used with other variable types.
Press + to interact
let string1 = 'Hello ';let string2 = 'there!';console.log(string1 + string2); // -> Hello there!
String addition just joins the strings together into a new, larger string.
NaN
What happens if we try to use the ...