Abdul Rawoof

Abdul Rawoof

21 Articles Published

Articles by Abdul Rawoof

Page 3 of 3

How do we check if an object is an array in Javascript?

Abdul Rawoof
Abdul Rawoof
Updated on 15-Mar-2026 365 Views

In JavaScript, typeof returns "object" for arrays, which makes it unreliable for array detection. There are three better approaches: Array.isArray(), the constructor property, and instanceof. The Problem with typeof typeof returns "object" for arrays, objects, and null − it cannot distinguish arrays from other objects ? let str = "Abdul Rawoof"; let arr = [1, 3, 5, 8]; let num = 90; let dict = {a: 1, b: 2}; console.log(typeof str); // "string" console.log(typeof arr); // "object" ← not "array" console.log(typeof num); // "number" console.log(typeof dict); // ...

Read More
Showing 21–21 of 21 articles
« Prev 1 2 3 Next »
Advertisements