Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

check if is array js

let names=['Jhon','David','Mark'];
console.log(Array.isArray(names));
// true

let user={id:1,name:'David'};
console.log(Array.isArray(user));
// false

let age 18;
console.log(Array.isArray(age));
// false
Comment

js is array

Array.isArray([1, 2, 3]);   // true
Array.isArray({toto: 123}); // false
Array.isArray("tototruc");  // false
Array.isArray(undefined);   // false
Comment

js check if is array

if(Array.isArray(colors)){
    //colors is an array
}
Comment

javascript Array.isArray

// all following calls return true
Array.isArray([]);
Array.isArray([1]);
Array.isArray(new Array());
Array.isArray(new Array('a', 'b', 'c', 'd'));
Array.isArray(new Array(3));
// Little known fact: Array.prototype itself is an array:
Array.isArray(Array.prototype);

// all following calls return false
Array.isArray();
Array.isArray({});
Array.isArray(null);
Array.isArray(undefined);
Array.isArray(17);
Array.isArray('Array');
Array.isArray(true);
Array.isArray(false);
Array.isArray(new Uint8Array(32));
Array.isArray({ __proto__: Array.prototype });
Comment

check if is array javascript

if(Object.prototype.toString.call(someVar) === '[object Array]') {
    alert('Array!');
}
Comment

PREVIOUS NEXT
Code Example
Javascript :: javascript remove first element from array 
Javascript :: javascript wrap object in array 
Javascript :: import error in react 
Javascript :: linear gradient react native 
Javascript :: sum range javascript 
Javascript :: subtrair datas javascript frontend 
Javascript :: regex expression for email 
Javascript :: supertest express check response 
Javascript :: define maxmum size of schema field in nodejs 
Javascript :: js date subtract minutes 
Javascript :: random function javascript 
Javascript :: js delete cookie by name 
Javascript :: range in javascript 
Javascript :: how to add multiple elements to A new array javascript 
Javascript :: nodejs heap usage 
Javascript :: foreach method of array in javascript 
Javascript :: sum of array javascript 
Javascript :: Beautifule JS Console Log 
Javascript :: javascript push and concat 
Javascript :: nested dto nestjs 
Javascript :: react navigation hide header 
Javascript :: react usememo vs usecallback 
Javascript :: nested navigation react native 
Javascript :: get list of text from div in js 
Javascript :: forever.js 
Javascript :: tinymce get plain text 
Javascript :: js count word 
Javascript :: else statement 
Javascript :: download pdf in javascript 
Javascript :: on hover display block jquery 
ADD CONTENT
Topic
Content
Source link
Name
3+4 =