Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

check if array has same values javascript

const allEqual = arr => arr.every(v => v === arr[0]);
allEqual([1,1,1,1]);  // true
Comment

js check if two arrays contain same values

const a = ['Left', 'Right'];
const b = ['Right', 'Left'];

//	true if a and b contain the same values
//	false otherwise
const c = a.sort().join(',') === b.sort().join(',');
Comment

js check if all array values are the same

const allEqual = arr => arr.every( v => v === arr[0] )
allEqual( [1,1,1,1] )  // true
Comment

check if two array contains the same values js, array

const areEqual = (arr1, arr2) =>
  arr1.sort().join(',') === arr2.sort().join(',');
const arr1 = [1, 2, 3, 4];
const arr2 = [3, 4, 1, 2];
const arr3 = [1, 2, 3];
console.log(areEqual(arr1, arr2)); // true
console.log(areEqual(arr1, arr3)); // false
Comment

PREVIOUS NEXT
Code Example
Javascript :: getcollectionnames 
Javascript :: jquery set a value in td 
Javascript :: generate random color javascript 
Javascript :: for in object javascript 
Javascript :: convert a string to a number in js 
Javascript :: get the value of css properties js 
Javascript :: js date now format 
Javascript :: compare NaN in javascript if condititon 
Javascript :: set image as background react 
Javascript :: jquery get text 
Javascript :: typescript css variables 
Javascript :: javascript generate 3 numbers 1 - 49 
Javascript :: js 2d array to object 
Javascript :: how to test usestate in jest 
Javascript :: javascript check if boolean is undefined 
Javascript :: how to right plain text format file in node js 
Javascript :: javascript deep clone 
Javascript :: event.target parent 
Javascript :: How do I push an element into the array within an object in AngularJS 
Javascript :: how to master javascript 
Javascript :: best javascript ide 
Javascript :: jquery replace text in button 
Javascript :: run function every second javascript 
Javascript :: create module with routing by angular 
Javascript :: req.url 
Javascript :: Toggle on button click in react js functional component 
Javascript :: refresh current component angular 
Javascript :: react onclick with event 
Javascript :: vue js required props 
Javascript :: query selector has clas 
ADD CONTENT
Topic
Content
Source link
Name
8+3 =