How can get unique data in a 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);
Leave a Reply