Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

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

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 :: queryselector 
Javascript :: axios timeout post example 
Javascript :: how to convert string to lowercase in javascript 
Javascript :: allow only numerics and few alphabets in input type js 
Javascript :: jquery get closest form 
Javascript :: how to include in ejs 
Javascript :: npm md5 
Javascript :: how to reverse number in javascript 
Javascript :: axios post with header 
Javascript :: sh: 1: react-scripts: not found 
Javascript :: on click button change route next js 
Javascript :: check all values from keys in object js 
Javascript :: js remove item from array by value 
Javascript :: js propagation stop 
Javascript :: __dirname is not defined 
Javascript :: javascript name capitalization 
Javascript :: js querySelectorAll map sample 
Javascript :: Putting password in a zip file using node.js 
Javascript :: how to fix Composer could not find a composer.json file in Z:xampp 7312htdocsproject_karakter-master 
Javascript :: sequelize migration add column foreign key 
Javascript :: typeahead cdn 
Javascript :: res.status 
Javascript :: bootstrap alert auto close 
Javascript :: jquery get td value 
Javascript :: clear swr cache 
Javascript :: how to get data from url in vuejs 
Javascript :: Jquery handle change event of file upload created dynamically 
Javascript :: javascript array flat 
Javascript :: link button material ui 
Javascript :: javascript disable resize window 
ADD CONTENT
Topic
Content
Source link
Name
5+6 =