Lesson Weekend

Now that you have the basics of HTML and CSS under your belt, we're going to start learning our first programming language: JavaScript.

In JavaScript, everything is either an object or a primitive. In this lesson, we'll cover primitives, which are the simplest elements of JavaScript. We will discuss objects further in a few weeks.

There are six different types of primitives in JavaScript. A primitive is immutable, which means it cannot change. Here are the five primitives we will see and use regularly during this course and beyond:

  • Number: A number is just what it sounds like. It could be 221, -4, or 1.97. As you might guess, we'll use these a lot.

  • String: A string is a set of characters enclosed in quotations. "hello" is a string. So is "Good morning, everyone!!!" And, just to make things a little tricky, "21" is a string, not a number. That's because it's enclosed in quotations, and any set of characters - whether that's letters, numbers, nineteen exclamation points in a row, or some combination thereof - is a string. We will be using strings all of the time.

  • Boolean: A boolean can be one of two values: true or false. That's it. We will use these a lot, too, and we will cover these in detail next week.

  • Null: Null just means nothing. We will sometimes want to assign a null value to a thing because we don't know what value it should have yet.

  • Undefined: This is a fun one... or rather, most of the time it's not so fun when it shows up in our code. It just means something hasn't been defined yet. The reason it's often not so fun is because we'll see that something is undefined in our code when we don't want it to be. This means there's a bug we need to fix. Don't worry, we will get a lot of practice with undefined, whether we want to or not!

And finally, here's the sixth, which is a newer primitive that was introduced in 2015:

  • Symbol: We won't be using this one during the program - and because we don't want to overwhelm you with too much information, we won't go into detail about it here. If you really must know more right this moment, see the Mozilla documentation on symbols.


Primitive: A simple element that can't change. JavaScript has six types of primitives.

Immutable: Something that can't change. All primitives are immutable.

Types of Primitives

  • Number: All numbers such as 221, -4, or 1.97.

  • String: A string is a set of characters enclosed in quotations. "hello" is an example.

  • Boolean: A boolean is either true or false.

  • Null: Null is nothing.

  • Undefined: This means something hasn't been defined in our code yet.

Lesson 4 of 61
Last updated June 1, 2020