How to check if an object or variable is an array, in JS?

JavaScript: How to check if an object or variable is an array, in JS?

To find out if an object or variable is an array, in Javascript, use Array.isArray(some_variable). It will return true or false.

webdevetc profile pic
webdevetc

I am a 29 year old backend web developer from London, mostly focusing on PHP and Laravel lately. This (webdevetc.com) is my blog where I write about some web development topics (PHP, Laravel, Javascript, and some server stuff). contact me here.



More...


Comments and discussion about How to check if an object or variable is an array, in JS?

Found this interesting? Maybe you want to read some more in this series?

Or see other topics in the JavaScript language

Or see other languages/frameworks:
PHP Laravel Composer Apache CentOS and Linux Stuff WordPress General Webdev and Programming Stuff JavaScript
Or see random questions

How to eager load multiple levels of relationships in Eloquent?

What is an example of an object literal?

How to prevent Eloquent from adding created_at or updated_at timestamps?

How to block multiple IP addresses in .htaccess

Set PHP config Variables (like ini_set) with .htaccess

How do you run a PHP script from the command line?

How to disable file hotlinking in Apache with .htaccess

When is __destruct called in PHP?

How to find an item by Primary Key in Eloquent, or throw a ModelNotFoundException exception if it isn't found?

How to find the index of a value in an array in JS?