Remove duplicate all unique values in multiple array Javascript [duplicate]
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.
javascript arrays
marked as duplicate by CertainPerformance
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.
add a comment |
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.
javascript arrays
marked as duplicate by CertainPerformance
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
add a comment |
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.
javascript arrays
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
javascript arrays
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
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
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
add a comment |
@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
add a comment |
1 Answer
1
active
oldest
votes
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);
@HamzahAznageel, you are most welcome:)
– Mamun
Nov 15 '18 at 4:50
add a comment |
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
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);
@HamzahAznageel, you are most welcome:)
– Mamun
Nov 15 '18 at 4:50
add a comment |
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);
@HamzahAznageel, you are most welcome:)
– Mamun
Nov 15 '18 at 4:50
add a comment |
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);
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);
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
add a comment |
@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
add a comment |
@CertainPerformance, sorry I have misspell my question
– Hamzah Aznageel
Nov 15 '18 at 4:30