I have written this small function to get all keys and values of an object and store them into an array. The object might contain arrays as values...
Object {
This solution can handle deeply nested objects
const isObject = o => o && typeof o === 'object' && !(o instanceof Date);
const flattenObject = obj => Object.entries(obj).reduce((acc, [key, val]) => ({
...acc, ...(isObject(val) ? flattenObject(val) : { [key]: val })
}), {});
Remember that this function returns an empty object for strings, dates, numbers, etc.