let num = 34; // A number without decimals
let price = 29.99;
A string can be any text and must be surrounded by quotes. You can use single or double
let name = ‘Tom’; let text = “My name is Tom Adams”;
You can use quotes inside a string, as long as they don’t match the quotes surrounding
let text = “My name is ‘Tom’ “;
These are useful when you need a data type that can only have one of two values, such as Yes/No, On/Off, True/False.
let isActive = true; let isAway = false;
Boolean values also come as a result of comparisons:
let isGreater = 6 > 2; alert(isGreater); // true (the comparison result is “yes”)
If you liked this article, then please share. You can also find me on Twitter for more updates.