Created
December 19, 2022 09:41
-
-
Save jkohlin/2185b655c8fde2d56f982c9c1690bcf8 to your computer and use it in GitHub Desktop.
Turn an object to an array of one-key-objects
This file contains 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
/** | |
* Description Splits out all keys from an object and returns them as separate objects with single key/value pairs | |
* @param {Object} obj | |
* @returns {Array} | |
*/ | |
function ArrayFromObject(obj) { | |
return Object.entries(obj).map(([v,k])=>({[v]:k})) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment