JSFiddle - React, Tailwind, and code Playground
JavaScript
var existing_names = ["username1", "username2", "username3"];
var new_names = ["username1", "username4", "username5"];
/* http://snook.ca/archives/javascript/testing_for_a_v */
function oc(a)
{
var o = {};
for(var i=0;i<a.length;i++)
{
o[a[i]]='';
}
return o;
}
for (var i=0; i < existing_names.length; i++) {
if (!(existing_names[i] in oc(new_names))) {
new_names.push(existing_names[i]);
}
}
console.log(new_names);