попробуй ты, а то я что то уже нехрена не пойму.
function compare(fArr,arr) {
var search = arr.slice(),
insert = [],
remove = [],
replace = [],
leng = fArr.length;
for(var i = 0, index; i < leng; i++) {
if(fArr[i] === arr[i]){
search[i] = undefined;
continue;
}
index = search.indexOf(fArr[i]);
if(!~index) {
remove.push(i);
continue;
}
i != index && replace.push({old: i, new: index});
search[index] = undefined;
};
for(i = 0, leng = search.length; i < leng; i++ ) {
if(search[i] !== undefined)
insert.push(i);
};
return {
remove: remove,
insert: insert,
replace: replace
}
}
function compare(fArr,arr) {
var search = arr.slice(),
insert = [],
remove = [],
replace = [],
leng = fArr.length;
for(var i = 0, index; i < leng; i++) {
if(fArr[i] === arr[i]){
search[i] = undefined;
continue;
}
index = search.indexOf(fArr[i]);
if(!~index) {
remove.push(i);
continue;
}
i != index && replace.push({old: i, new: index});
search[index] = undefined;
};
search.forEach(function (elem, i) {
if(elem !== undefined)
insert.push(i);
});
return {
remove: remove,
insert: insert,
replace: replace
}
}