is array also an object javascript 1

is array also an object javascript

// Prove that Array is also an Object in JavaScript
// Method -1
let arr = [];
console.log(typeof arr);

// Method -2
let arr2 = [];
if (Array.isArray(arr2)) {
   console.log(`Array is an Object in JavaScript`);
}

Here is what the above code is Doing:
1. We created an empty array and checked its type using typeof operator.
2. We created another empty array and checked if it is an array using Array.isArray() method.

Similar Posts