-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathisArray.js
37 lines (31 loc) · 1.32 KB
/
isArray.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
'use strict';
// TOPIC /////////////////////////////////////////////////////////////////////////////////////////////////////
//
// Array Method: Array.isArray()
//
// SYNTAX ////////////////////////////////////////////////////////////////////////////////////////////////////
//
// Array.isArray(value)
//
// SUMMARY ///////////////////////////////////////////////////////////////////////////////////////////////////
//
// • Array.isArray determines whether the value passed is an array or not.
// • Array.isArray will return either true or false.
//
// EXAMPLES //////////////////////////////////////////////////////////////////////////////////////////////////
//
// EXAMPLE 1: Check if the value is an array.
//
// RESOURCES /////////////////////////////////////////////////////////////////////////////////////////////////
//
//////////////////////////////////////////////////////////////////////////////////////////////////////////////
// EXAMPLE 1: Check if the value is an Array.block
const array1 = "This is a string, not an array";
const array2 = { arr: [1,2,3,4,5,6] };
const array3 = ["alan", "bob", "charlie", "dan"];
function isArray(input) {
return Array.isArray(input);
}
console.log(isArray(array1)); // false
console.log(isArray(array2)); // false
console.log(isArray(array3)); // true