<p>Click the button to generate the unique array</p>

<p>Duplicates array:</p>

<pre><code>['mike','james','james','alex'];</code></pre>

<button>Generate unique array</button>

<p>Unique array: <pre><code class="unique"></pre></code></p>
var duplicatesArray = ['mike','james','james','alex'];

var uniqueArray = duplicatesArray.filter(function(elem, pos) {
  return duplicatesArray.indexOf(elem) == pos;
});

$('button').on('click',function(){
  $('.unique').empty();
  $('.unique').append('[');
  for (var i=0; i<uniqueArray.length;i++){
    $('.unique').append("'" + uniqueArray[i] +"',");
  }
  $('.unique').append(']');
  
});

External CSS

This Pen doesn't use any external CSS resources.

External JavaScript

  1. https://code.jquery.com/jquery-2.2.4.min.js