Created
May 27, 2016 02:45
-
-
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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