Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

js check if a variable is an array

let fruit = 'apple';
let fruits = ["apple", "banana", "mango", "orange", "grapes"];

const isArray = (arr) => Array.isArray(arr);

console.log(isArray.(fruit)); //output - false
console.log(isArray.(fruits)); //output- true
Source by dev.to #
 
PREVIOUS NEXT
Tagged: #js #check #variable #array
ADD COMMENT
Topic
Name
8+2 =