Bladephp: Now with 8+ codeigniter, php, and laravel project 8+ php project From $37/Month From Rs. 2499/Month

How can get unique data in different array using JavaScript

by
Category:javascript
javascript jquery
How can get unique data in different array using JavaScript

The concat() method is used to join two or more arrays and find unique() function to unique array. The $.unique() function searches through an array of objects, sorting the array, and removing any duplicate nodes. A node is considered a duplicate if it is the exact same node as one already in the array; two different nodes with identical attributes are not considered to be duplicates. This function only works on plain JavaScript arrays of DOM elements, and is chiefly used internally by jQuery.

var data1 = ['a','b','c'];
var data2 = ['b','c','d'];
var data3 = ['c','d','e'];
var finaldata = data1.concat(data2,data3);
var unique = finaldata.filter(function(elem, index, self) {
	  return index == self.indexOf(elem);
});
console.log(unique);

0 Comments


Html code work in comment box


Related Post