0

Without using typeof, how can you check if a variable is an array?

author
subina kallyani
easy
3
71

Answer
Array.isArray(variable);

This returns true if the variable is an array, and false otherwise.

let arr = [1, 2, 3];
console.log(Array.isArray(arr)); // true

Click to Reveal Answer

Tap anywhere to see the solution

Revealed

Comments0
    Without using typeof, how can you check if a variable is an array? - array | EBAT