---
title: "Discussion on \"🔥 How to check if something is an array in JavaScript\" | Hashnode"
description: "Discussion on \"🔥 How to check if something is an array in JavaScript\". Internally, there is no type called “array” in JavaScript. When used on an array, typeof returns \"object\" instead.\nTo check if something is an array, use Array.isArray() instead.\n// `typeof` an array returns “object” because JS has no type called “ar..."
url: "https://hashnode.com/posts/how-to-check-if-something-is-an-array-in-javascript/5fe0d1e77cd4e55d1d465e6b"
---

[Feed](https://hashnode.com/feed) /

Discussion

# [🔥 How to check if something is an array in JavaScript](https://domhabersack.hashnode.dev/how-to-check-if-something-is-an-array-in-javascript?utm_source=hashnode&utm_medium=feed)

Internally, there is no type called “array” in JavaScript. When used on an array, typeof returns "object" instead. To check if something is an array, use Array.isArray() instead. // \`typeof\` an array returns “object” because JS has no type called “ar...

Dec 21, 2020 · 1 min read · domhabersack.hashnode.dev  
Read the article

-   [#javascript](https://hashnode.com/tag/javascript)

## Written by

[Dom Habersack](https://hashnode.com/@domhabersack)

@domhabersack

  
[View profile](https://hashnode.com/@domhabersack)

Teaching everything I know.

## Responses 1

Markdown supported · ⌘↵ to post

[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]';
  }
};
```

[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/5ff29c9ea3903205a6666b27)

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]';
  }
};
```
