---
title: "Comment by Purvi Barot on \"🔥 How to check if something is an array in JavaScript\" | Hashnode"
description: "In modern browsers you can do: Array .isArray(obj) For backward compatibility you can add the following: // only implement if no native implementation is availa"
url: "https://hashnode.com/posts/how-to-check-if-something-is-an-array-in-javascript/5fe0d1e77cd4e55d1d465e6b/comment/5ff29cf955aabd0578224a12"
---

[Discussion](https://hashnode.com/posts/how-to-check-if-something-is-an-array-in-javascript/5fe0d1e77cd4e55d1d465e6b)

Comment [🔥 How to check if something is an array in JavaScript](https://hashnode.com/posts/how-to-check-if-something-is-an-array-in-javascript/5fe0d1e77cd4e55d1d465e6b)

[Purvi Barot](https://hashnode.com/@purvi)

[Jan 4, 2021](https://hashnode.com/posts/how-to-check-if-something-is-an-array-in-javascript/5fe0d1e77cd4e55d1d465e6b/comment/5ff29cf955aabd0578224a12)

In modern browsers you can do:

```
Array.isArray(obj)
```

For backward compatibility you can add the following:

```
// only implement if no native implementation is available
if (typeof Array.isArray === 'undefined') {
  Array.isArray = function(obj) {
    return Object.prototype.toString.call(obj) === '[object Array]';
  }
};
```
