Chapter 2. Primitive Data Types, Arrays, Loops, and Conditions

Before diving into the object-oriented features of JavaScript, let's first take a look at some of the basics. This chapter walks you through the following topics:

  • The primitive data types in JavaScript, such as strings and numbers
  • Arrays
  • Common operators, such as +, -, delete, and typeof
  • Flow control statements, such as loops and if...else conditions

Variables

Variables are used to store data; they are placeholders for concrete values. When writing programs, it's convenient to use variables instead of the actual data as it's much easier to write pi instead of 3.141592653589793; especially when it happens several times inside your program. The data stored in a variable can be changed after ...

Get Object-Oriented JavaScript - Third Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.