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 use Anonymous classes in PHP 7?

How to view all installed PHP modules?

How to get the first row that matches some where queries, or create it if it doesn't exist (in Laravel's Eloquent)?

How to force gzip compression in Apache with .htaccess

How to sort an array of dates and times?

How to show a specific view file for certain error codes?

How to access the Laravel's route parameters outside of the controller?

What are PHP's PSRs?

How to Force www or non-www in htaccess

How to check if a user is logged in, inside a blade file?