showing results for - "check if 2 arrays are equal javascript"
Michela
25 Oct 2018
1const a = [1, 2, 3];
2const b = [4, 5, 6];
3const c = [1, 2, 3];
4
5function arrayEquals(a, b) {
6  return Array.isArray(a) &&
7    Array.isArray(b) &&
8    a.length === b.length &&
9    a.every((val, index) => val === b[index]);
10}
11
12arrayEquals(a, b); // false
13arrayEquals(a, c); // true
Andrea
14 Nov 2019
1var arraysMatch = function (arr1, arr2) {
2
3	// Check if the arrays are the same length
4	if (arr1.length !== arr2.length) return false;
5
6	// Check if all items exist and are in the same order
7	for (var i = 0; i < arr1.length; i++) {
8		if (arr1[i] !== arr2[i]) return false;
9	}
10
11	// Otherwise, return true
12	return true;
13
14};
15
queries leading to this page
two arrays are equal javascriptcheck if two arrays are equal or notcheck two arrays are equal in javascripthow check two arrays for same values javascripttwo arrays eqals javascriptcheck if 2 arrays are equal javascripthow to compare if two arrays are equal in javascriptcan we use 3d 3d 3d to compare equality of 2 array in javascriptcheck if both arrays are equal in jscompare arrays check if they are the same javascripthow to check for equality of two arrays in javascriptjavascript check two arrays equalcheck if arrays are same javascriptjs if two arrays have same valueshow to check 2 arrays is same or not in javascriptjs check if 2 arrays are similarhow to check if 2 lists are equal in jschecking if two arrays are equalcheck two array have equal values in jsjs checking for 2 equal arayshow to check if arrays are equal javascriptcheck if array matchescheck if 2 different order arrays is equal javascriptjavascript how to test if two arrays are equalcheck if two arrays are the same javascripthow to check if two arrays are equal to each other in javascriptjavascript 2 array equalcompare between 2 arrays are equal javascriptjavascript compare if two arrays are exact the samecheck if 2 arrays have same values javascripthow to check if 2 array elements are same or not in javascripttwo arrays are equal if they contain the same elements javascriptcompare if 2 arrays are same in jshow to chech if two arrays are same in jsjavascript check arrays for equalitycheck if two arrays are equal and return count javascriptjavascript check 2 arrays are the samehow to see if two arrays are the same in jshow to check if two values in an array are equal jscheck if two arrays strictly equal javascriptcheck if arrays are equal javascripthow to compare if two arrays are equal in javascriptcheck if all elements in two arrays are equal javascriptwhy two arrays are not equal in javascriptbuilt in angulat array equality functionshow to check two arrays are identical jshow to check if two arrays are equal with javascript 3f es6javascript if arrays are equalnot equal in compare two arrays javascripthow to check if two array element are equal in javascriptjavascript check if 2 arrays are the samehow can i check two array is same or not in javascript 3fmethod to check if 2 arrays have same elements jscheck if arrays are the same javascriptwhat is the most efficient way to check two arrays are equal javascriptcheck if any values from 2 arrays are same javascriptarray equals javascriptcheck wether the 2 strings in an array are same in javascripthow to check if two content element in array javascript is equalhow to check is 2 arrays are equal in javascriptjavascript check if two arrayhow to check if two arrays are equal in length regardless of their order and value javascriptcheck if 2 array is equel jscompare if two arrays are equal irrespective of order jscheck if sum of 2 arrays is equal jscheck if two arrays match any value javascriptcheck array equality in jshow to check if two array value are equal in javascriptjavascript two arrays equal but not samecheck if both arrays are same in javascripthow to check if two arrays are same value with javascript 3f es6javascript check arrays are equalhow to check if 2 arrays are equal in jscompare two array javascript and check if value existstest list of arrays against one arraycompare if two arrays are equal javascripthow to check if two arrays are equivalent in jstest if 2 arrays are the same jsjs check two arrays are equalcheck equality of two arrays in javascripthow to check if two array are equal in javascripthow to check if value of two array is equal in javascriptcheck if n arrays are equal javascriptcheck if two arrays are equal javascript es6what is being compared when checking if two arrays are the same in javascriptcheck two arrays are equal javascriptarray equal javascriptjavascript check if 2 arrays have same valueseverting in arrays same jsjavascript check if two arrays share an elementhow to see if 2 numbers in an array are equal in javascriptcheck if two arrays have the same values javascripthow to check if two arrays are equal without check the order javascriptjs check if two arrays have same valuescheck if two arrays is same javascripthow to check if 2 arrays are equal in javascript nodehow to check if two arrays of strings are equal t in javascripthow to check if two arrays are equal in typescriptcompare if two arrays are equal jshow to find out if two arrays are equal javascripthow to check if 2 arrays are the same 2c javascripthow to check if 2 arrays are same in javascriptcreate an equal two arrays javascriptchecking if 2 arrays are equaljavascript check if 2 arrays contain same valuesjavascript check if two arrays have same elementscheck if 2 arrays have any same values javascriptcheck if two arrays are equal javascript nativeelycheck if two arrays are identical javascriptcompare array of numbers javascriptjavascript see if two arrays are equalhow to check if 2 arrays are equal in javascripthow to check equality of two arrays in javascriptcheck two arrays equal javascriptcheck if two arr are equal jsjavasscript check if oevrlap two arrayshow to check if two arrays are equal for loopsjavascript how to check if two arrays are the samecheck if 2 arrays are equal jscheck if array deep equaltest if 2 arrays are equalif two arrays are equal javascriptjavascript check if 2 arrays have the same elementshow can i compare 2 arrays to see if they are equal jshow to check if two arrays are equal javascript esjavascript if two arrays contain some equal valueshow to check if two values in an array are equal javascripthow to check if 2 different arrays match javascriptjavascript how to check if two arrays matchjs check if two arrays contain the same valuejavascript two arrays equaljavascript check if multiple equal variables in arraycheck if two arrays are equalcheck if two arrays are equal in javascriptcheck if array is equaljavascript check if array samejs two arrays equalcan you check for equality in two arrays in javascriptcompare if two arrays are the same javascriptjs if arrays are samehow to check if one array has two same values in javascriptcheck if two lists are equal javascriptjs array equal to arrayhow to check two arrays are equal in javascriptjavascript two arrays where thry are not equaljavascript check if two string arrays have same elementsjavascript check to see if 2 arrays are equaljs check if two lists are equalhow to compare two array are equal on not in javascriptcheck if two arrays are equal or not jsto check if two arrays are equal jsjs compare if arrays are equalcheck if elements in two arrays are equal typescriptto check two arrays are equal in javascriptcheck if an element in an 2 array is the same jscheck if two arrays in nodejs have the same elementscheck two arrays are equalcompare if length of two different arrays is equal javascripthow to check the values of 2 arrays that are same in javscripthow to check if two arrays are equal javascriptcheck array is same value and arrangement javascripthow to check if two arrays are equal jscheck if array is equal to 1js compare 2 array if has same valuejavascript check if 2 arrays contain same order of valuesarray equals jsjs array equality 27 27how to check if two arrays values are same in javascriptcompare 2 arrays are equal jsjavascript check if array is equal to another arrayhow to check two arrays reference are same javascriptjavascript check if it is the same or differentcheck value have two array javascriptcheck if two array has same values javascriptjs check if 2 arrays have same valuesjavascript if two arrays are equalcheck two array are equal in jscheck two array equal in jsjs compare if two array are equalhow to check if an array has two same values in javascriptjavascript make check two arrays sametypescript know if two arrays are equal or notjavascript test if two arrays are equal es6check if two arrays are equal javascripttypescript check if two arrays are equalhow to check if both the arrays have any comon value in jscheck if two arrays contains same value javascriptcheck if two array are equalcheck if two arrays are equal or not javascriptcheck if 2 arrays are the same javascriptcheck lists are equal javscriptcheck if two vectors have values in common jshow to check if two arrays have the same elements javascriptchecking if two array are equal javascriptcheck if 2 arrays have same values jscheck if two array has some value equal javascriptcheck if 2 arrays are equalcompare if two arrays are equal in value javascriptcheck if two array length are equal javascriptjavascript how to check if two arrays are equalcheck if any given arrays are equal javascripthow to check if two arrays are the same javascriptcheck if 2 arrays have same valuesjavascriptcheck if 2 arrays are identical jstwo array equal javascriptcheck to see if 2 arrays have same elements javascriptjs equal arraysjs check if 2 arrays are the sameif array 3d 3d array jstest is two arrays are identical javscriptjs two array equalhow to check if two elements in array equal a number javascriptjs two element array equalhow to check equality of two array in jsjs var equals arrayhow to check if 2 different arrays match javascriptyhow to check if two array are same in jscheck to see if contents of two arrays are equal javascriptarray equality javascriptverify if two arrays are equal javascriptcompare if arrays are equal javascriptjavascript return true or false if two array has same numbercheck 2 arrays are equal javascripthow to check two array values are equal in javascriptcompare two arrays is equal or not in jsjs check if two array has the same valuesjs array equal checkjavascript check if two arrays are the samejavascript check if 2 arrays are equalhow ot check if 2 array are equaljavascript fuction to check if two diffrent arrays are the samejs equal between two arraysjs check if two arrays have same elementscheck if number belongs in two array javascriptcheck array equals javascriptjavascript check equality of arrayschecking two arrays are equal javascriprhow to check array equality jscheck if items are equal in two arrays javascriptjs check if two arars are equalare two arrays equal javascriptjavascript check if array is one of two valuesverify if two arrays are equalcompare two arrays javascript if values are equalcheck if two arrays are equal in jsjquery javascript check if two array have same ordertest if two arrays are equal javascriptcheck if 2 arrays are equal javascript different ordercheck if 2 arrays have a matching element javascripthow to check if two arrays are same value with javascript 3f es6 score javascript check if two arrays have same elementshow to check if two arrays are equal nodejshow check if two arrays is the same jscan two arrays be equal javascriptcheck if two arrays ar same jscheck two arrays for equality in jscompare if two arrays has same elements jscheck two values in array equal jsjs check if two strings in array samejavascript check if two arrays contain the same elementsjs does two array values are equalcheck if two arrays have same elements javascriptjavascript check if 2 arrays are equivalenthow to check if two arrays are equal in javascripthow to check if two array are equalcompare trwo array equality 2c javascripttwo arrays equal javascripttwo array equal or not in jsjavascript compare arrays equalwhy do no two arrays equal in javascriptjavascript testing if two arrays are equalnode js two array check samecheck if two arrays have the same elements javascripthow to check two arrays are same in javascriptjavascript to check both the array are same or notcheck if two array are equal in javascriptjavascript comparing if 2 arrays are equalhow to check if two values in an array of javascript are equalcheck if two arrays have same elements in different order javascriptjavascript check if arrays are differentcheck if two lists are equal jscan two arrays be equal in jshow to check array has 2 same value jshow to compare if array is equal to function javascriptjavascript test if two arrays are equaljavascript compare if two arrays are equalcheck if two arrays are equal typescripthow to verify that 2 arrays are equal in javascripthow to verify if there is a equall inside two array javascripthow to check if two arrays hold the same elements jsjavascript check if two arrays are equaljs check if 2 arrays have the same valuecheck if two arrays are identical jshow to check if two elements in array equal a number jshow to check if two arrays have same elements javascriptcompare if all the arrays in an object are of same lengthjavascript includes check two arrays equaljs check if 2 arrays are identicalnodejs check if values in 2 arrays are differentjs test if two arrays are equalcheck if arrays are identical javascriptjavascript check if at least one element in two arrays are equalhow verify if 2 arrays contains the same data javascriptjavascript check if arrays are samejs array equality check 27 27javascript array equaljavascript check two arrays are the samehow to check if two list are equal in jsnodejs check if values in 2 arrayscompare two arrays javascript if notjs check two arrays equalsee if two arrays are equal in jsjavascript comparing arrays for equalitycheck if 2 array are equal jscheck if array is equal javascriptjavascript check if both numbers of an array are equalwhy are two arrays in javascript not equalhow to check if two elements in array are equal jshow to check if all arrays are equal jshow to check if two elements in an array are equal javascriptarray equals array javascriptcheck if element in both arrays javascriptcheck if two arrays are same javascriptcheck if two arrays are equal or not in javascriptjavascript determine if arrays are equaljs check if value in 2 arrayscheck same value in two arrays javascriptjs functions that checks if two arrays are equaljavascript check if two multidimentional arrays have same elementsjs check 2 arrays equaljavascript check list equalitycheck if two arrays are equal jsarray equals jsjs equality matrixhow to check if two arrays are equal to each other javscirpthow to check if 2 arrays have same elements in javascriptcheck if two array have same value javascripthow to check if two arrays are equal or not in javascripthow to check if an array is the same as anotherjavascript check if 2 array are the sametwo arrays with the same content are equal javascripthow to test if two arrays are equal in javascriptcompare two arrays if same values javascriptjavascript comparing if two arrays are the samejs check two arrays are samejavasc ript array equlityhow to chekc if two arrays are the same jsarray equals javascriptcheck elements of two arrays are equal javascripthow to check two array elements are equal in javascriptsee if two arrays are equal javascripthow to check if two arrays elements are equal javascriptjs array equaljavascript array equals arrayjavascript check if two array number equal valuescheck if two arrays have same elements jscheck if numbers of arrays are identical javascriptcheck if array is the same javascriptjavascript check if two array are equaljavascript check if two arrays have same elements es6check if tow array not equal jshow to see if two arrays are equal in javascriptcheck if 2 arrays are equal irrespective of order jsjavascript array equalityjs arrays equaljs find equal elements in two arrayscheck two arrays are equal jshow to check if two arrays are same in javascriptarray is not equal another array javascriptjavascript check two arrays are equalcomparing two arrays value is exist in javascriptcompare two arrays are equal jsjavascript compare if one element exist in two arraysif array item is more than onecompare if 2 arrays are the same in javascriptwhen are 2 arrays same value in javascriptjavascript check if two lists are equalhow to check if two arrays are identical javascripthow to check if two element in array javascript is equaljs check if 2 arrays are equalhow to check if an item is in both arrays in javascript 3fwhy 2 array with same value are not equal in javascriptjs check if two arrays are equalcheck if two elements in array are equal jsjs 2 array equaljs array 3d 3d arraycheck if 2 arrays are equal javascript