_.uniq = function(array, isSorted, iterator) {
var uniqueArray = [];
var storeObj = {};
var iteratorArray = [];
_.each(array, function(item, index) {
if (iterator) {
iteratorArray.push(iterator(item));
} else {
iteratorArray.push(_.identity(item));
}
});
_.each(iteratorArray, function(item, index) {
if (storeObj[item] === undefined) {
storeObj[item] = array[index];
}
});
for(var key in storeObj) {
uniqueArray.push(storeObj[key]);
}
return uniqueArray;
};
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter