Skip to content

Instantly share code, notes, and snippets.

@uuz2333
Created May 27, 2016 02:45
Show Gist options
  • Save uuz2333/7eb7dc1582b0c27232eac490cf13b084 to your computer and use it in GitHub Desktop.
Save uuz2333/7eb7dc1582b0c27232eac490cf13b084 to your computer and use it in GitHub Desktop.
get uniq Objects array from an array that contain some objects which has same property by es6 systax
export default function uniqObjectsArray(objects) {
/*
objects is an array of Object
*/
let keys = [];
let arr = [];
arr = objects.filter(row => {
let key = JSON.stringify(row);
if (!keys[key]) {
keys[key] = '-';
return true;
}
});
return arr;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment