In this chapter we have built up knowledge of the fundamentals of JavaScript's data types and variables, and how to use them in operations. In particular, we saw that
JavaScript supports a number of types of data, such as numbers, text, and Booleans.
Text is represented by strings of characters and surrounded by quotes. You must match the quotes surrounding strings. Escape characters allow you to include characters in your string that cannot be typed.
Variables are JavaScript's way of storing data, such as numbers and text, in memory so that they can be used again and again in your code.
Variable names must not include certain illegal characters, like % and &, or be a reserved word, like with.
Before we can give a value to a variable, we must declare its existence to the JavaScript interpreter.
JavaScript has the four basic math operators, represented by the symbols +, -, *, and /. To assign values of a calculation to a variable we use the = sign, termed the assignment operator.
Operators have a different precedence, so multiplication and division will be calculated before addition and subtraction.
Strings can be joined together, or concatenated, to produce one big string, using the + operator. When numbers and strings are concatenated with the + operator, JavaScript automatically converts the number into a string.
Although JavaScript's automatic data conversion suits us most of the time, there are occasions when we need to force the conversion of data. We saw how parseInt() and parseFloat() can be used to convert strings to numbers. Attempting to convert strings that won't convert will result in NaN (Not a Number) being returned.
Arrays are a special type of variable that can hold more than one piece of data. The data is inserted and accessed using a unique index number.