Last active
September 24, 2020 08:26
-
-
Save jonguenther/c52b429f6f4fadcdbc241e8972bab011 to your computer and use it in GitHub Desktop.
Jon's Javascript collection
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
// get array of unique keys in array of objects | |
const getUniqueKeys = (ArrayOfObjects) => new Set(ArrayOfObjects.reduce((acc, cur) => [...acc, ...Object.keys(cur)], [])); | |
// conditional properties inside objects | |
const fooCondition = false; | |
const conditionalObject = { | |
someProperty: 'foo', | |
...(fooCondition && { bar: true }), | |
anotherProperty: 'bar', | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment