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 {
Generate an array of tuples (two-element arrays) of keys and values (which might themselves be arrays), then deep-flatten it.
function flattenObject(obj) {
return flatten(Object.keys(obj).map(k => [toNumber(k), obj[k]]));
}
// Substitute your own favorite flattening algorithm.
const flatten = a => Array.isArray(a) ? [].concat(...a.map(flatten)) : a;
// Convert to number, if you can.
const toNumber = n => isNaN(+n) ? n : +n;
console.log(flattenObject({a: [1, 2], b: 3, 0: [1, 2, 3, 4, 5]}));