Primitive vs Non-Primitive
Primitives are immutable and compared by value. Objects (including arrays and functions) are compared by reference. This fundamental difference affects how variables behave when assigned, compared, and passed as arguments.
Primitive types include: number, string, boolean, null, undefined, symbol, and bigint. These are the basic building blocks that cannot be broken down further.
Non-primitive types (objects) include: Object, Array, Function, Date, RegExp, and user-defined classes. These are complex types that can contain multiple values and methods.
Immutability of primitives means operations on them create new values rather than modifying existing ones. This leads to different performance characteristics and memory usage patterns.