Chapter 2Programming Basics

In the last chapter, we introduced JavaScript and set up a programming environment where we got our hands dirty with a few JavaScript programs. In this chapter, we’re going to delve further to learn how JavaScript works, and start writing some programs.

We’ll cover the following topics:

  • the importance of well-commented code

  • JavaScript grammar―expressions, statements, semicolons, and whitespace

  • primitive data types

  • strings―string literals and string methods such as length

  • variables―declaring and assigning

  • numbers―decimal, hexadecimal, octal and exponent form, Infinity, and NaN

  • arithmetic operations such as +, -, *, /, and %

  • undefined and null

  • Booleans―truthy and falsy values

  • logical operators―AND, OR, and ...

Get JavaScript: Novice to Ninja 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.