Wrapping Up
In this chapter, you started learning the fundamental lessons of real programming in JavaScript, centered around the simple variable types. Those types include numbers, strings, and Booleans. You learned how to declare variables, how to properly name them, and how to assign them simple values.
Next, the chapter looked into the number type in detail, which starts with basic arithmetic. From there, you saw how to use the Number and Math object methods in this object-oriented language to perform such commonplace tasks as formatting numbers and rounding them.
After numbers, similar treatment was given to strings: what they are and how to create them. You also learned that there are several methods defined within the String object that are usable on any string you have. One of the most common manipulations of strings is concatenation, accomplished via the plus sign. Attention was also given to using the backslash as an escaping character.
The chapter concluded with a discussion of type conversion between numbers and strings. Implicit conversion can lead to bugs, as demonstrated, so it’s best to formally convert values when needed. Along the way you also started creating practical examples, mostly as mathematical calculators.
This knowledge will be expanded in the next chapter, where you will learn about control structures. These are primarily conditionals and loops, but Chapter 5 will introduce more operators, too, before Chapter 6 gets into more complicated variable types.