JavaScript Datatypes
A datatype tells what kind of value you have.
Numbers, words, yes or no, lists, and objects are different kinds.
Think of a toy shelf. Soft toys, cars, and books live in different spots.
Why types matter
Primitive types
Non primitive types
How to check a type
Why types matter
You add numbers.
You glue strings.
If you mix them by accident, the result can surprise you.
Two big families
Primitive values are simple single values.
Non primitive values can hold many parts, like arrays and objects.
Primitive: string, number, boolean, null, undefined, symbol, bigint
Non primitive: object, array, function, and more
Check with typeof
typeof tells you the type name as a string.
Dynamic typing
In JavaScript, a variable can hold one type today and another tomorrow.
That is flexible.
It also means you should watch your values carefully.
What comes next
The next lessons look at primitive types one by one.
Then we look at bigger containers like arrays and objects.
Tip: When something looks weird, print typeof. It often reveals the mix up.
Test yourself
Three quick questions made just for this lesson. Earn 10 XP per correct answer.