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

What is the difference between var, let and const in Javascript?

How do you launch the PHP interactive shell?

How to autoload helper files with composer?

How to set the Expires header in .htaccess

What are generators in PHP, and how do they compare to arrays?

What are the predefined variables in PHP?

How to sort an array of dates and times?

How to manually write your own pagination in PHP

How to set up an alias to map one directory to another destination

What is the difference between ( for ... in ) and ( for ... of ) in javascript?