JavaScript Glossary - Lesson #3

JavaScript Array .isArray() Method

The isArray() method checks if the specified parameter is an array. It returns a Boolean.

javascript
Array.isArray('my thing goes here'); // false
js
console.log(Array.isArray('one')); // false

console.log(Array.isArray(['thing1', 'thing2'])); // true

This method takes one parameter:

  • value: the provided value to be checked

It returns true if the provided value is an Array and false if not.

js
Array.isArray('one'); // false
Array.isArray(1); // false
Array.isArray(['first']); // true
Array.isArray({checked: true}); // false

Checking if a value is an Array.

js
const names = ['Pete', 'John', 'Mary'];
const isArray = Array.isArray(names);

console.log(isArray); // true

Want to improve your coding and design skills?

I'm continually researching the best practices and tools for coding.
Join 50,000+ developers looking to make cool stuff.

We value your privacy. 1-click unsubscribe.

Chris Sev

Chris Sev

Chris Sev is the co-founder of Better Dev. Coding better every day. Previously he created Scotch.io which was acquired.

Comments

What did you think of the article? Let us know!
(these comments are powered by GitHub issues and use 0 trackers)