- Primitive values
- Non-primitive values (object references)
The fundamental difference between primitives and non-primitive is that primitives are immutable and non-primitive are mutable.
Primitives are known as being immutable data types because there is no way to change a primitive value once it gets created. They are compared by value. Two values are strictly equal if they have the same value.
Non-primitive values are mutable data types. The value of an object can be changed after it gets created. Objects are not compared by value. This means that even if two objects have the same properties and values, they are not strictly equal. The same goes for arrays. Even if they have the same elements that are in the same order, they are not strictly equal.
Non-primitive values can also be referred to as reference types because they are being compared by reference instead of value. Two objects are only strictly equal if they refer to the same underlying object.