var arr = [],
arrLng = 6000,
out=[];
for (var i = 0; i < arrLng; i++) {
arr.push(parseInt(Math.random()*arrLng))
}
//====== Deff =========
var st = +new Date(),
bound = ',';
out=[];
var tststr = bound + arr.join(bound+bound) + bound;
for (var i = 0; i < arr.length; i++) {
var t = bound +arr[i] + bound;
if(tststr.indexOf(t)==tststr.lastIndexOf(t))out.push(arr[i])
}
var work = +new Date()-st;
alert('Deff ='+work+'\n\n'+out)
//===== danik ==========
var st = +new Date();
out=[];
for (var i = 0; i < arr.length; i++) {
var item = arr[i];
if (arr.indexOf(item, i + 1) === -1 && (i === 0 || arr.lastIndexOf(item, i - 1) === -1))
out.push(item);
}
var work = +new Date()-st;
alert('danik ='+work+'\n\n'+out)
//===== рони ==========
var st = +new Date();
out=[];
arr.sort(function (a, b) {
return a - b;
});
for (var i = 0; i < arr.length; i++) {
var item = arr[i];
if (item != arr[i - 1] && arr[i + 1] != item)
out.push(item);
}
var work = +new Date()-st;
alert('рони ='+work+'\n\n'+out)
В Опере 12.6 и Ие быстрее первая метода, в Хроме и Мозилле - вторая