What are "Data Types"?

In a previous chapter we explored values, and decided they are just the "things" that we can access inside of our programs. But when we say "things", we really mean something like "pieces of data".

In programming, values are just the pieces of data we can access inside of our program.

"Data" is at the heart of programming, and in programming we generally have multiple different types of data (such as numbers or lists). So a data type is really just a type of data 🤷.

The typeof operator

Recall that an operator are tools for taking one or more values and turning them into a new value (like addition). JavaScript has a typeof operator (which is just "type of" condensed into a single word) that will tell us the type of any value. Let's check this operator out real quick.

$log( typeof 13 );
200px x 200px
Log
Nothing to see here...
Use $log to log things here.

Let's break this down a bit. We're using $log to print some text to our log. We're looking at typeof 13 which looks at the value 13 and gives us the data type of that value. Hopefully this isn't too surprising: JavaScript is telling us that 13 is a number!

There are a handful of basic data types in JavaScript, and we'll be exploring a few of these in the upcoming chapters. We'll start with numbers, because these should be familiar to you.