𝗝𝗮𝘃𝗮𝗦𝗰𝗿𝗶𝗽𝘁 𝗗𝗮𝘁𝗮 𝗧𝘆𝗽𝗲𝘀: 𝗣𝗿𝗶𝗺𝗶𝘁𝗶𝘃𝗲 𝘃𝘀 𝗡𝗼𝗻-𝗣𝗿𝗶𝗺𝗶𝘁𝗶𝘃𝗲

Data types define the value a variable holds. You need this knowledge to write clean code.

JavaScript uses two main categories.

Primitive Data Types These store one simple value. They are immutable.

Non-Primitive Data Types These store complex data. They are mutable.

Comparison rules:

Primitives compare by value. Two variables with the number 10 are equal.

Non-primitives compare by reference. Two objects with the same data are not equal. They occupy different memory spots.

Pick the right type to stop bugs.

Source: https://dev.to/sivasakthi_paramasivam_e8/javascript-data-types-explained-primitive-vs-non-primitive-data-types-3ea9