Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

javascript remove duplicate in two arrays

array1 = array1.filter(function(val) {
  return array2.indexOf(val) == -1;
});
// Or, with the availability of ES6:

array1 = array1.filter(val => !array2.includes(val));
Comment

filter duplicates from array javascript

// usage example:
var myArray = ['a', 1, 'a', 2, '1'];
var unique = myArray.filter((v, i, a) => a.indexOf(v) === i);

console.log(unique); // unique is ['a', 1, 2, '1']
 Run code snippet
Comment

filter repetition multidimensional array javascript

var arr = [[7,3], [7,3], [3,8], [7,3], [7,3], [1,2]];

arr.map(JSON.stringify).reverse().filter((e, i, a) => a.indexOf(e, i+1) === -1).reverse().map(JSON.parse) // [[7,3], [3,8], [1,2]]
Comment

PREVIOUS NEXT
Code Example
Javascript :: jquery import js file 
Javascript :: Web History API 
Javascript :: mongoose countdocuments 
Javascript :: convert array to object 
Javascript :: js get node index 
Javascript :: reverse text javascript 
Javascript :: print chart js 
Javascript :: js add array to array 
Javascript :: map array method create object 
Javascript :: remove element from array by name javascript 
Javascript :: get url query in react 
Javascript :: continue foreach javascript 
Javascript :: remove object in array javascript 
Javascript :: fetching data with react 
Javascript :: react context 
Javascript :: javascript url pas array 
Javascript :: jquery select element after this 
Javascript :: regex email 
Javascript :: cast object to string javascript 
Javascript :: countdown javascript 
Javascript :: js retour à la ligne 
Javascript :: queryselectorall in javascript to get data attribute value 
Javascript :: change text in html with javascript 
Javascript :: string to array angular 
Javascript :: how to get a particular line from a file in nodejs 
Javascript :: express send code 
Javascript :: javascript ternary operator 
Javascript :: li dots 
Javascript :: image in react jsx 
Javascript :: MAC addresses in JavaScript 
ADD CONTENT
Topic
Content
Source link
Name
4+9 =