Remove duplicate all unique values in multiple array Javascript [duplicate]










0
















This question already has an answer here:



  • Remove duplicate values from JS array [duplicate]

    54 answers



  • How to merge two arrays in JavaScript and de-duplicate items

    70 answers



I have data like this:



var data1 = ["RFCC","HCC","RFCC"];
var data2 = ["RFCC"];


I want to remove all duplicates from array above, the output should be like this:



var result = ["RFCC","HCC"];


If possible, how I could do the following task? Maybe someone could help me? Thanks in advance.










share|improve this question















marked as duplicate by CertainPerformance javascript
Users with the  javascript badge can single-handedly close javascript questions as duplicates and reopen them as needed.

StackExchange.ready(function()
if (StackExchange.options.isMobile) return;

$('.dupe-hammer-message-hover:not(.hover-bound)').each(function()
var $hover = $(this).addClass('hover-bound'),
$msg = $hover.siblings('.dupe-hammer-message');

$hover.hover(
function()
$hover.showInfoMessage('',
messageElement: $msg.clone().show(),
transient: false,
position: my: 'bottom left', at: 'top center', offsetTop: -7 ,
dismissable: false,
relativeToBody: true
);
,
function()
StackExchange.helpers.removeMessages();

);
);
);
Nov 15 '18 at 4:32


This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.


















  • @CertainPerformance, sorry I have misspell my question

    – Hamzah Aznageel
    Nov 15 '18 at 4:30















0
















This question already has an answer here:



  • Remove duplicate values from JS array [duplicate]

    54 answers



  • How to merge two arrays in JavaScript and de-duplicate items

    70 answers



I have data like this:



var data1 = ["RFCC","HCC","RFCC"];
var data2 = ["RFCC"];


I want to remove all duplicates from array above, the output should be like this:



var result = ["RFCC","HCC"];


If possible, how I could do the following task? Maybe someone could help me? Thanks in advance.










share|improve this question















marked as duplicate by CertainPerformance javascript
Users with the  javascript badge can single-handedly close javascript questions as duplicates and reopen them as needed.

StackExchange.ready(function()
if (StackExchange.options.isMobile) return;

$('.dupe-hammer-message-hover:not(.hover-bound)').each(function()
var $hover = $(this).addClass('hover-bound'),
$msg = $hover.siblings('.dupe-hammer-message');

$hover.hover(
function()
$hover.showInfoMessage('',
messageElement: $msg.clone().show(),
transient: false,
position: my: 'bottom left', at: 'top center', offsetTop: -7 ,
dismissable: false,
relativeToBody: true
);
,
function()
StackExchange.helpers.removeMessages();

);
);
);
Nov 15 '18 at 4:32


This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.


















  • @CertainPerformance, sorry I have misspell my question

    – Hamzah Aznageel
    Nov 15 '18 at 4:30













0












0








0









This question already has an answer here:



  • Remove duplicate values from JS array [duplicate]

    54 answers



  • How to merge two arrays in JavaScript and de-duplicate items

    70 answers



I have data like this:



var data1 = ["RFCC","HCC","RFCC"];
var data2 = ["RFCC"];


I want to remove all duplicates from array above, the output should be like this:



var result = ["RFCC","HCC"];


If possible, how I could do the following task? Maybe someone could help me? Thanks in advance.










share|improve this question

















This question already has an answer here:



  • Remove duplicate values from JS array [duplicate]

    54 answers



  • How to merge two arrays in JavaScript and de-duplicate items

    70 answers



I have data like this:



var data1 = ["RFCC","HCC","RFCC"];
var data2 = ["RFCC"];


I want to remove all duplicates from array above, the output should be like this:



var result = ["RFCC","HCC"];


If possible, how I could do the following task? Maybe someone could help me? Thanks in advance.





This question already has an answer here:



  • Remove duplicate values from JS array [duplicate]

    54 answers



  • How to merge two arrays in JavaScript and de-duplicate items

    70 answers







javascript arrays






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 15 '18 at 5:05









Abana Clara

1,666919




1,666919










asked Nov 15 '18 at 4:27









Hamzah AznageelHamzah Aznageel

198




198




marked as duplicate by CertainPerformance javascript
Users with the  javascript badge can single-handedly close javascript questions as duplicates and reopen them as needed.

StackExchange.ready(function()
if (StackExchange.options.isMobile) return;

$('.dupe-hammer-message-hover:not(.hover-bound)').each(function()
var $hover = $(this).addClass('hover-bound'),
$msg = $hover.siblings('.dupe-hammer-message');

$hover.hover(
function()
$hover.showInfoMessage('',
messageElement: $msg.clone().show(),
transient: false,
position: my: 'bottom left', at: 'top center', offsetTop: -7 ,
dismissable: false,
relativeToBody: true
);
,
function()
StackExchange.helpers.removeMessages();

);
);
);
Nov 15 '18 at 4:32


This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.









marked as duplicate by CertainPerformance javascript
Users with the  javascript badge can single-handedly close javascript questions as duplicates and reopen them as needed.

StackExchange.ready(function()
if (StackExchange.options.isMobile) return;

$('.dupe-hammer-message-hover:not(.hover-bound)').each(function()
var $hover = $(this).addClass('hover-bound'),
$msg = $hover.siblings('.dupe-hammer-message');

$hover.hover(
function()
$hover.showInfoMessage('',
messageElement: $msg.clone().show(),
transient: false,
position: my: 'bottom left', at: 'top center', offsetTop: -7 ,
dismissable: false,
relativeToBody: true
);
,
function()
StackExchange.helpers.removeMessages();

);
);
);
Nov 15 '18 at 4:32


This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.














  • @CertainPerformance, sorry I have misspell my question

    – Hamzah Aznageel
    Nov 15 '18 at 4:30

















  • @CertainPerformance, sorry I have misspell my question

    – Hamzah Aznageel
    Nov 15 '18 at 4:30
















@CertainPerformance, sorry I have misspell my question

– Hamzah Aznageel
Nov 15 '18 at 4:30





@CertainPerformance, sorry I have misspell my question

– Hamzah Aznageel
Nov 15 '18 at 4:30












1 Answer
1






active

oldest

votes


















1














You can first concatenate the arrays into a single array. Then use filter() by passing the current item, index and the array itself to check whether the indexOf of the current item is the current index or not.



Try the following way:






var data1 = ["RFCC","HCC","RFCC"];
var data2 = ["RFCC"];
var res = data1.concat(data2);
res = res.filter((value, idx, self) =>
return self.indexOf(value) === idx;
);
console.log(res);








share|improve this answer

























  • @HamzahAznageel, you are most welcome:)

    – Mamun
    Nov 15 '18 at 4:50

















1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes









1














You can first concatenate the arrays into a single array. Then use filter() by passing the current item, index and the array itself to check whether the indexOf of the current item is the current index or not.



Try the following way:






var data1 = ["RFCC","HCC","RFCC"];
var data2 = ["RFCC"];
var res = data1.concat(data2);
res = res.filter((value, idx, self) =>
return self.indexOf(value) === idx;
);
console.log(res);








share|improve this answer

























  • @HamzahAznageel, you are most welcome:)

    – Mamun
    Nov 15 '18 at 4:50















1














You can first concatenate the arrays into a single array. Then use filter() by passing the current item, index and the array itself to check whether the indexOf of the current item is the current index or not.



Try the following way:






var data1 = ["RFCC","HCC","RFCC"];
var data2 = ["RFCC"];
var res = data1.concat(data2);
res = res.filter((value, idx, self) =>
return self.indexOf(value) === idx;
);
console.log(res);








share|improve this answer

























  • @HamzahAznageel, you are most welcome:)

    – Mamun
    Nov 15 '18 at 4:50













1












1








1







You can first concatenate the arrays into a single array. Then use filter() by passing the current item, index and the array itself to check whether the indexOf of the current item is the current index or not.



Try the following way:






var data1 = ["RFCC","HCC","RFCC"];
var data2 = ["RFCC"];
var res = data1.concat(data2);
res = res.filter((value, idx, self) =>
return self.indexOf(value) === idx;
);
console.log(res);








share|improve this answer















You can first concatenate the arrays into a single array. Then use filter() by passing the current item, index and the array itself to check whether the indexOf of the current item is the current index or not.



Try the following way:






var data1 = ["RFCC","HCC","RFCC"];
var data2 = ["RFCC"];
var res = data1.concat(data2);
res = res.filter((value, idx, self) =>
return self.indexOf(value) === idx;
);
console.log(res);








var data1 = ["RFCC","HCC","RFCC"];
var data2 = ["RFCC"];
var res = data1.concat(data2);
res = res.filter((value, idx, self) =>
return self.indexOf(value) === idx;
);
console.log(res);





var data1 = ["RFCC","HCC","RFCC"];
var data2 = ["RFCC"];
var res = data1.concat(data2);
res = res.filter((value, idx, self) =>
return self.indexOf(value) === idx;
);
console.log(res);






share|improve this answer














share|improve this answer



share|improve this answer








edited Nov 15 '18 at 4:45

























answered Nov 15 '18 at 4:38









MamunMamun

28.6k71831




28.6k71831












  • @HamzahAznageel, you are most welcome:)

    – Mamun
    Nov 15 '18 at 4:50

















  • @HamzahAznageel, you are most welcome:)

    – Mamun
    Nov 15 '18 at 4:50
















@HamzahAznageel, you are most welcome:)

– Mamun
Nov 15 '18 at 4:50





@HamzahAznageel, you are most welcome:)

– Mamun
Nov 15 '18 at 4:50





這個網誌中的熱門文章

How to read a connectionString WITH PROVIDER in .NET Core?

In R, how to develop a multiplot heatmap.2 figure showing key labels successfully

Museum of Modern and Contemporary Art of Trento and Rovereto