Skip to content

Instantly share code, notes, and snippets.

@jkohlin
Created December 19, 2022 09:41
Show Gist options
  • Save jkohlin/2185b655c8fde2d56f982c9c1690bcf8 to your computer and use it in GitHub Desktop.
Save jkohlin/2185b655c8fde2d56f982c9c1690bcf8 to your computer and use it in GitHub Desktop.
Turn an object to an array of one-key-objects
/**
* 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