JavaScript Basics #4: Data Types

Love it? Share it!

In programming, we use the various kinds of data. To make a distinction, there are seven types of data in JavaScript. Except for the object data type that you already learned about (remember console?), the rest of them are so called primitives.

These are all the data types available in JavaScript:

  1. Number
  2. String
  3. Boolean
  4. Null
  5. Undefined
  6. Symbol
  7. Object


This data type represents any kind of number, including numbers with decimals like 15.45.


String is a group of characters (letters, numbers, symbols) available on the keyboard. The important thing is that strings are always surrounded by quotes, preferably single quotes '....'. String is just a fancy word for a regular text.


This data type represents logical state and has only two possible mutually exclusive values. It’s either true or false (notice it’s without quotes, so it’s not a string). You can think of Boolean as a switch that can be on or off.


Null means an intentional absence of a value. It’s represented by the keyword null (again, without quotes as it’s not a string).


Another data type that represents the absence of a value, but it has a different use than null. Undefined is represented by the keyword undefined (again, no quotes).


Symbol is a new addition to JavaScript, useful in more complex programming. You don’t need to worry about it for now, just remember that it exists.


Object represents a collection of related data and actions performed on such data. Unlike all the data type above, object is not a primitive, it’s a complex data type.

Before we move on, let’s practice the difference between strings and numbers. First, we will print a string surrounded by quotes. As you can see below, it’s a whole sentence composed of different words, spaces, and punctuation.

console.log('My name is Jan. My website is available at');

Next, we will print the number 40. Notice that in this case, we won’t use quotes.

Love it? Share it!
Jan Zavrel
Jan Zavrel

Jan Zavrel is an author, teacher, online entrepreneur and Evernote Certified Consultant who runs multiple projects focused on productivity, fitness, web development and passive income. He is also active as an instructor on Udemy and Skillshare. His books are available via Amazon.