Javascript Data Type Checker Is Array

Description

Javascript Data Type Checker Is Array



// Checks to see if something is an Array
Object.isArray = function(obj) {
    // test to see if it is an object and its constructor is an array
    return (typeof obj == 'object' && obj.constructor == Array)
}

let a = new Array();
console.log(Object.isArray(a));//from   ww  w. j a va  2s. com

let b = false;
console.log(Object.isArray(b));



PreviousNext

Related