Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

how to recognize an array in javascript

const array = [1, 2, 3];

Array.isArray(array);  // => true
Array.isArray(object); // => false
Array.isArray(string); // => false
Array.isArray(empty);  // => false

// other ways

({}).toString.call(array);   // => '[object Array]'
({}).toString.call(object);  // => '[object Object]'
({}).toString.call(string);  // => '[object String]'
({}).toString.call(empty);   // => '[object Null]'
Comment

PREVIOUS NEXT
Code Example
Javascript :: discord.js reason 
Javascript :: export html table to excel 
Javascript :: date format in jquery 
Javascript :: react setstate in another component 
Javascript :: how to use the foreach method in javascript 
Javascript :: json schema validator allows null 
Javascript :: how to remove last element from array in javascript 
Javascript :: how to mock a library in jest 
Javascript :: pass array from controller to javascript blade 
Javascript :: print string multiple times in javascript 
Javascript :: function prototype in javascript 
Javascript :: javascript console 
Javascript :: useeffect hook 
Javascript :: one component to another component in vuejs trigger function 
Javascript :: array.push 
Javascript :: js html editor 
Javascript :: how to assign variables in javascript 
Javascript :: date format in moment js 
Javascript :: how to sort array least to greatest javascript stACK 
Javascript :: isotope js 
Javascript :: threemeshphonematerial url image three js 
Javascript :: how to concatenate in javscript 
Javascript :: getboundingclientrect 
Javascript :: how to get variable from url in javascript 
Javascript :: how to use findoneandupdate 
Javascript :: enable swipe using javascript 
Javascript :: react router path array 
Javascript :: js array last element 
Javascript :: context api 
Javascript :: split and join in javascript 
ADD CONTENT
Topic
Content
Source link
Name
1+2 =