Objects (including arrays, as you already know) are considered to be complex data types. Strings, numbers, booleans are considered to be simple, or primitive data types. They are often called so - primitives, meaning everything that is not an object.
JavaScript has seven primitive data types: string, number, boolean, null, undefined⁅/y ⁆, symbol, bigint. Remember their number and names are often asked in interviews.
Given the following code:
let test = {x: 1, y: 2, z: 3};
console.log(test);
What type of data will be output to the console? Is it a primitive or an object?
Given the following code:
let test = {x: 1, y: 2, z: 3};
console.log(test.x);
What type of data will be output to the console? Is it a primitive or an object?
Given the following code:
let test = [1, 2, 3];
console.log(test);
What type of data will be output to the console? Is it a primitive or an object?
Given the following code:
let test = [1, 2, 3];
console.log(test[1]);
What type of data will be output to the console? Is it a primitive or an object?
Given the following code:
let test1 = [1, 2, 3];
let test2 = 1;
console.log(test1);
What type of data will be output to the console? Is it a primitive or an object?
Given the following code:
let test1 = [1, 2, 3];
let test2 = 1;
console.log(test1[test2]);
What type of data will be output to the console? Is it a primitive or an object?
List all primitive data types in JavaScript without looking into the tutorial.