Skip to content

Instantly share code, notes, and snippets.

@gemmadlou
Last active August 30, 2017 18:42
Show Gist options
  • Select an option

  • Save gemmadlou/16da1158efa686e62298949707927f3a to your computer and use it in GitHub Desktop.

Select an option

Save gemmadlou/16da1158efa686e62298949707927f3a to your computer and use it in GitHub Desktop.
Object to array
let delimiter = ':';
Object.keys(obj).reduce((a, b) => {
return obj[b] !== undefined ? a.concat(b + delimiter + obj[b]) : a;
}, []);
@gemmadlou

gemmadlou commented Aug 30, 2017

Copy link
Copy Markdown
Author
class whatever {
   objectToArray(obj, separator) {
        let delimiter = separator || ' ' ;
        return Object.keys(obj).reduce((a, b) => {
        	return obj[b] !== undefined ? a.concat(b + delimiter + obj[b]) : a;
        }, []);
    }
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment