var fractal = {
a1: {
b1: {
c: 1
},
b2: {
c: 222
},
b3: {
c: {
d: 33,
e: 2.5,
f: {
g: 9999,
h: {
i: {
j: 1001,
k: 'строка',
l: [1,2,3],
m: function() {}
}
}
}
}
}
}
}
function getProp(o) {
for(var prop in o) {
if(typeof(o[prop]) === 'object') {
getProp(o[prop]);
} else {
//return o[prop];
console.log(o[prop]);
}
}
}
getProp(fractal);
//console.log(getProp(fractal));
const getPrimitiveProps = (obj) =>
Object.entries(obj).reduce((acc, [ k, v ]) => ({
...acc,
...(v instanceof Object ? getPrimitiveProps(v) : { [k]: v }),
}), {});
const getPrimitiveProps = (obj) =>
Object.assign({}, ...Object.entries(obj).map(([ k, v ]) =>
v instanceof Object ? getPrimitiveProps(v) : { [k]: v }
));