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

check array values equal js

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

PREVIOUS NEXT
Code Example
Javascript :: require statement not part of import statement javascript 
Javascript :: reference body js 
Javascript :: javascript typeof undfined 
Javascript :: javascript check if undefined or null 
Javascript :: convert to small case in javascript 
Javascript :: javascript print subarray from index to indeex 
Javascript :: remove empty or whitespace strings from array javascript 
Javascript :: unique array javascript es6 Map 
Javascript :: window is not define nextjs 
Javascript :: delete empty values from object js 
Javascript :: javascript get domain 
Javascript :: javascript play sound onclick 
Javascript :: order datatable 
Javascript :: prime factorization javascript 
Javascript :: jquery change text of div 
Javascript :: jquery validation on button click 
Javascript :: disable default sorting in datatable 
Javascript :: open page in new tab using jquery 
Javascript :: get rid of header bar react native 
Javascript :: laravel jquery ajax post csrf 
Javascript :: js refresh button 
Javascript :: convert number to k m b javascript 
Javascript :: next js active link 
Javascript :: copy text to clipboard javascript react 
Javascript :: javascript hasownproperty 
Javascript :: $ is not defined 
Javascript :: expressjs hello world 
Javascript :: jquery left arrow key press 
Javascript :: for each element in obj js 
Javascript :: how to make javascript make things disappear 
ADD CONTENT
Topic
Content
Source link
Name
9+3 =