Answers for "how to check array or not in javascript"

2

javascript check if any value in array is true

let boolArray1 = [true, false, false]
let boolArray2 = [false, false, false]

boolArray1.some(x => x);  // true
boolArray2.some(x => x);  // false

// Example of using a function to evaluate array
let numberArray = [1, 2, 3, 4, 5];
let oddNumbers = [1, 3, 5, 7, 9];

// checks whether an element is even
const even = (element) => element % 2 === 0;

numberArray.some(even);  // true
oddNumbers.some(even);   // false
Posted by: Guest on October-01-2020
2

how to check if something is array javascript

function isArray(value) {
    return Object.prototype.toString.call(value) === "[object Array]";
}
Posted by: Guest on May-06-2020
0

javascript check if array is in array

var array = [1, 3],
    prizes = [[1, 3], [1, 4]],
    includes = prizes.some(a => array.every((v, i) => v === a[i]));

console.log(includes);
Posted by: Guest on June-29-2020
0

check variable is array or not in javascript

// npm i is-js-array 
const { isJSArray } = require("is-js-array");
isJSArray([]); // true
isJSArray({}); // false
Posted by: Guest on August-31-2021

Code answers related to "how to check array or not in javascript"

Code answers related to "Javascript"

Browse Popular Code Answers by Language