Skip to content

Instantly share code, notes, and snippets.

@bzupnick
bzupnick / deleteDuplicates.js
Last active December 25, 2015 16:49
easy to understand function to delete duplicated elements in an array
function deleteDuplicates(arr) {
arr.sort();
var lastElement = '';
var arrDuplicate = arr;
for (var i = arrDuplicate.length; i >= 0; i--) {
if (arrDuplicate[i] == lastElement) {
arr.splice(i, 1);
}
lastElement = arrDuplicate[i];
}