Chapter 3

Using Data

IN THIS CHAPTER

Bullet Using let and const to store data

Bullet Introducing JavaScript's data types

Bullet Creating and using objects

Bullet Storing lists with arrays

Bullet Understanding JavaScript scope

“A foolish consistency is the hobgoblin of little minds.”

—RALPH WALDO EMERSON

At its most basic level, programming is the process of changing values. Sometimes, however, you specifically don't want to change certain values. In this chapter, you'll see how to create and modify constants and variables, and you’ll learn the rules for working with values in JavaScript.

Making Variables with let

Variables are names that represent values in a program. JavaScript has the let keyword for creating new variables.

Declaring variables

Creating a new variable is known as declaring a variable. To declare a variable using let, simply write the let keyword followed by what you want to name the variable, like this:

let phoneNumber;

This line creates a new empty variable named phoneNumber.

Technically, a ...

Get JavaScript All-in-One For Dummies 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.