Variables can store various types of data in their container. Before going into it any further, it is important to first address the categories within types of data. A single value can either be categorized as an object or a primitive value. For this post, I will only talk about primitive values and explain object values in a future post (as it is easier to follow-through that way 🙂).
1) Number: Any number value that is shown as either a decimal or an integer.
let age = 23; let decimal = 1.01;
2) String: Sequence of characters used for text.
let firstName = 'John'; let lastName = 'Smith';
3) Boolean: Logical type that can only be true or false which is used for taking decisions.
let isTrue = true; let isFalse = false;
4) Undefined: a value taken by a variable that is not yet defined ('empty value').
5) Null: similar to undefined, null also means 'empty value', but done intentionally.
let container = null;
6) Symbol (ES2015): a value that is unique and cannot be changed.
7) BigInt (ES2020): larger integers than the Number type can hold.
let word = 'hello' typeof word; // 'string' let num = '1'; typeof num; // 'number' let isTrue = true; typeof isTrue; // 'boolean'