Non-Primitive Datatypes
Non primitive datatypes can hold many pieces together.
They are like toy chests, not single stickers.
Objects, arrays, and functions are the main ones you will meet.
Objects
Arrays
Functions as values
How they differ from primitives
Objects
An object stores named values.
Each name is a key. Each value sits beside it.
Think of a student card with name, age, and grade.
Arrays
An array stores an ordered list.
Items get numbers called indexes.
The first item is at index 0.
Functions are values too
A function can be stored in a variable.
That means you can pass it around like a toy.
Shared boxes
Primitives copy the value itself.
Objects and arrays share the same box when you assign them.
Changing one name can change what the other name sees.
typeof reminders
typeof an array says object.
typeof a function says function.
Use Array.isArray when you need to know if something is a list.
Tip: Use objects for labeled facts. Use arrays for ordered lists. Keep that picture in your head.
Test yourself
Three quick questions made just for this lesson. Earn 10 XP per correct answer.