Remove duplicate values from one array using prototype function.
This free javascript can be used to remove duplicate values in single array using the javascript array prototype function. The array prototype function can be used anywhere to remove duplicates from an array.
Features
Give any repeated values with comma separated in the textarea
Just click the Remove Duplicates button
You can have sorted list of strings or numbers without repeated values
Preview
Deleting Duplicate values in single array:
Downloads
Prototype Function
<!--Script by hscripts.com--> <!-- Free javascripts @ https://www.hscripts.com --> <script type="text/javascript"> Array.prototype.sort = function() { for(i=0;i<this .length;i++) { for(j=i+1;j<this.length;j++) { if(Number(this[i]) >Number(this[j])) { temp = this[j]; this[j] = this[i]; this[i] = temp; } } } } Array.prototype.removeDuplicate = function() { // Here we remove duplicate values from first array var array4 = new Array; for(var i=0; i<this.length; i++) {var xx = true; for(var j=i+1; j<this.length; j++) { if(this[i] == this[j]) xx = false; } if(xx == true) array4.push(this[i]); } return array4; } </script> <!-- Script by hscripts.com -->
Javascript Code
<!--Script by hscripts.com--> <!-- Free javascripts @ https://www.hscripts.com --> <script type="text/javascript"> function del1array() {var str1=document.txtchk.val1.value; var array1 = str1.split(','); array1 = array1.removeDuplicate(); alert(array1); } </script> <!-- Script by hscripts.com -->