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 convert between types in JS?

How to check if a object has a static variable defined?

How to make multiple routes share the same URL structure or URL parameters

How to sort an array in javascript?

How to redirect your website to a new domain/location in .htaccess

What are macros in Laravel?

How to find the 2nd most common item in an array?

How to manually write your own pagination in PHP

How to install jpegtran for Linux CentOS

How to set environmental variables in your .htaccess file