Lecture 3: Data Types in JavaScript

Topic: Understanding Primitive and Non-Primitive Data Types

1. Connecting Variables to Data Types

In the previous lecture, we learned about variables, variable declarations, and hoisting. We understood that variables allow us to store values and use them throughout our programs.

Consider:

let age = 22;
let name = "Aman";
let isStudent = true;

We have declared three variables. However, notice something:

All three variables store different kinds of values.

This brings us to an important question:

How does JavaScript know what kind of value is stored inside a variable?

The answer is: Data Types.

What is a Data Type?

A data type defines the kind of value a variable holds and the operations that make sense for that value.

For example:

let price = 500;
let product = "Laptop";
let available = true;

Here: