Data types used in JS
For now, we will only focus on the first 5.
In the examples on the previous page, you saw that we can add the values of x and y together and get the result. The result was a number just like the two initial values (x and y)..
The typeof() operator returns the data type - in this case of the variable z
A string consist of a single character or a combination of characters:
When assigning strings as values, always write them in quotation marks.
If we write a number inside quotation marks, the data type will be string. Strings don't "add up" the same way that numbers do. 1 + 1 = 2 when the data type is number, but "1" + "1" = "11" when the data type is string.
Log the code from the example 1.0 in the console again, but this time type in the values in quotation marks, changing the data type to string. Add the two values, just like in the example.
Use the typeof() operator to find out what the data type of z is.
The Boolean data type has two possible values: true or false
This data type is often used in connection with conditional statements.
What's next?Next up: The JS Document