Javascript examples for Array Operation:Array Element
Array Remove Duplicate Results from array
<html> <head> <meta name="viewport" content="width=device-width, initial-scale=1"> <script type="text/javascript"> window.onload=( function() {/*from ww w . j a v a2 s .c o m*/ function unique(arr) { var unique = [], map = {}; for (var i = 0; i < arr.length; i++) { var exists = map[arr[i]]; console.log(exists); if (!exists) { unique.push(arr[i]); map[arr[i]] = true; } } return unique; } document.write(unique([1,1,1,1,1,1,3,3,3,3,3,3,2,2,1,4,4,3,5,5])); }); </script> </head> <body> </body> </html>