As elements are yet ordered, you don't have to build a map, there's a fast solution :
var newarr = [arr[0]];
for (var i=1; i
If your array weren't sorted, you would use a map :
var newarr = (function(arr){
var m = {}, newarr = []
for (var i=0; i
Note that this is, by far, much faster than the accepted answer.