Topic: Understanding Primitive and Non-Primitive 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:
age contains a number.name contains text.isStudent contains a Boolean value.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.
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:
500 is a Number.