Best way to return duplicate elements in an Array
<p>Here is the way I am using to return duplicate elements..  But I am facing most dangerous performance issues like browser close etc when my array have large number of items with long texts..  </p>

<pre><code>var arr = [9, 9, 111, 2, 3, 4, 4, 5, 7];
var sorted_arr = arr.sort();
var results = [];
for (var i = 0; i &lt; arr.length - 1; i++) {
  if (sorted_arr[i + 1] == sorted_arr[i]) {
     results.push(sorted_arr[i]);
  }
}
alert(results);
</code></pre>

<p>Please suggest me a best way of doing this  </p>
