Remove duplicate from two arrays using the prototype function

This free javascript can be used to concatenate two array values after removing the duplicates.


  • Give any repeated values in both the textareas with comma(,) seperated.
  • Just click the Remove Duplicates button.
  • This function shows concatenated list of strings or numbers without repeated values.


Remove duplicates and concatenate two arrays:

Concatenated list of strings without repeated values.



Javascript Code

<!--Script by>
<!-- Free javascripts @ -->
<script type="text/javascript">
function deldup()
var str1=document.strchk.val1.value;
var str2=document.strchk.val2.value;
var array1 = str1.split(',');
var array2 = str2.split(',');
var array3 = arrayUnique(array1.concat(array2));
document.getElementById('val3').value = array3;
alert('Enter Values');
function arrayUnique(array) {
var a = array.concat();
for(var i=0; i<a.length; ++i) {
for(var j=i+1; j<a.length; ++j) {
if(a[i] === a[j])
a.splice(j--, 1);
return a;}function chk(){
var sds = document.getElementById('dum');
if(sds == null){alert("You are using a free package.\n You are not allowed to remove the tag.\n");
var sdss = document.getElementById("dumdiv");
if(sdss == null){alert("You are using a free package.\n You are not allowed to remove the tag.\n");}
<!-- Script by -->

Css Code

<!--Script by>
<!-- Free javascripts @ -->
.frms textarea{min-height:100px !important;resize:none;font-family: Tahoma,Geneva,sans-serif;font-size: 1.31em;line-height: 18px;min-height: 200px;padding: 5px 0.5%;background: none repeat scroll 0 0 #fff;border: 1px solid #ddd;border-radius: 0.35em;height: auto;margin-bottom: 15px;margin-top: 5px;padding: 1% 0.5%;width: 80%;}
.frms textarea:focus {border: 1px solid #9d9983;box-shadow: 7px 4px 7px -7px rgba(0, 0, 0, 0.42) inset;

.frms textarea:hover
box-shadow:#dae1e5 0px 0px 5px;
-moz-box-shadow:#dae1e5 0px 0px 5px;
-webkit-box-shadow:#dae1e5 0px 0px 5px;
-o-box-shadow:#dae1e5 0px 0px 5px;
input[type="button"]{background: none repeat scroll 0 0 #468cd2;border-bottom: 3px solid #3277bc;text-shadow: 1px 1px 0 #214d73;border: medium none;border-radius: 0.3em;color: #fff;cursor: pointer;font-weight: bold;margin: 10px 0;padding: 7px 14px;}
.frms {border: 1px solid #ddd;border-radius: 0.3em;color: #333;font-family: Tahoma,Geneva,sans-serif;font-size: 0.9em;line-height: 1.2em;margin: 0 auto;padding: 10px;width:50%;}
@media only screen and (max-width:650px) {
.frms textarea{width:100% !important;}.frms { width:auto;}

<!-- Script by -->

Html Code

<!--Script by>


<head> </head>

<div align='center'>
<b>Remove duplicates and concatenate two arrays:</b> <br>
<form name="strchk" class='frms' id='maindiv'>
<textarea id="val1" rows="1" cols="50"></textarea><br>
<textarea id="val2" rows="1" cols="50"></textarea><br><br>
<input type="button" value="Remove Duplicates" onclick="deldup()" >
<p><b>Concatenated list of strings without repeated values.</b></p>
<textarea id="val3" cols="50" onclick="this.focus();">
<div id="dumdiv" align="center" style=" font-size: 10px;color: #dadada;">
<a id="dum" style="padding-right:0px; text-decoration:none;color: green;text-align:center;" href="">©h</a>



<!-- Script by -->

  • Get free version without ©copyright link for just $10/-
  • For customization of this script or any script development, mail to


  • Copy the HTML code given above and save it with .php extension.
  • Just copy and paste the javascript code given above in <head> section.
  • Then copy the CSS code and paste it in <head> section.
  • Values entered in the arrays are concatenated and displays the result without any duplication in the resultant text area.


Related Scripts

Free Javascript Scripts

Ask Questions

Ask Question