Arrays are actually a special case of objects.
This can be verified by checking the array
through the operator typeof
:
console.log(typeof []); // shows 'object'
Without running the code, determine what will be output to the console:
console.log( typeof {x: 1, y: 2, z: 3} );
Without running the code, determine what will be output to the console:
console.log( typeof [1, 2, 3] );
Without running the code, determine what will be output to the console:
let arr = [1, 2, 3];
console.log( typeof arr );
Without running the code, determine what will be output to the console:
let arr = [1, 2, 3];
console.log( typeof arr[0] );
Without running the code, determine what will be output to the console:
let arr = ['1', '2', '3'];
console.log( typeof arr[0] );