Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

is array equal javascript

// comparing arrays to check for equality - method 1
const a = [1, 2, 3];
const b = [4, 5, 6];
const c = [1, 2, 3];

function arrayEquals(a, b) {
    return Array.isArray(a) &&
        Array.isArray(b) &&
        a.length === b.length &&
        a.every((val, index) => val === b[index]);
}

arrayEquals(a, b);
// false
arrayEquals(a, c);
// true
Comment

how to check all values of an array are equal or not in javascript

// how to check all values of an array are equal or not in javascript
const allEqual = (arr) => arr.every(val => val === arr[0]);
console.log(allEqual([1, 2, 3, 4, 5, 6])); // false
console.log(allEqual([1, 1, 1, 1])); // true
Comment

check array values equal js

[1,1,1,1].every( (val, i, arr) => val === arr[0] )   // true
Comment

PREVIOUS NEXT
Code Example
Javascript :: how check if a form date is before today javascript 
Javascript :: how to add d3.js in angular 
Javascript :: randomize an array in javascript 
Javascript :: react native build android 
Javascript :: react router route not found redirect 
Javascript :: useref() in react 
Javascript :: empty input field on click 
Javascript :: react native vector icon 
Javascript :: Use parseInt() in the convertToInteger function so it converts a binary number to an integer and returns it. 
Javascript :: iso 8601 date to Js date 
Javascript :: How to check if an item is selected from an HTML drop down list with javascript js 
Javascript :: how to make your own drop down react native 
Javascript :: p5.js 
Javascript :: redirect to download javascript 
Javascript :: javascript array split empty string 
Javascript :: javascript array filter 
Javascript :: declare an array nodejs 
Javascript :: liquid object 
Javascript :: react native pm ERR! code EINTEGRITY 
Javascript :: how avoid populate mongoose return password 
Javascript :: js queryselector find without attribute 
Javascript :: momentjs 
Javascript :: how to make text channels in discord.js 
Javascript :: array of string mongoose 
Javascript :: use these instead of a for loop javascript 
Javascript :: popup in browser js 
Javascript :: js password check 
Javascript :: networkx check if node exists 
Javascript :: react must be in scope when using jsx 
Javascript :: uml diagram javascript 
ADD CONTENT
Topic
Content
Source link
Name
8+3 =