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 are some ways you can log debug messages and data in JS?

How to show (or log) all SQL queries executed by Laravel

How to replace values in a string, in JS

How to exclude URLs from the Laravel CSRF protection?

What are the predefined variables in PHP?

What is camel case?

How to convert a string to an array of it's characters in PHP?

How to check if a relation was loaded on an Eloquent model already?

How to merge/concat two arrays together in JS?

How to query mysql using PDO in PHP?