JSFiddle - React, Tailwind, and code Playground
JavaScript
var o = {
Id: 1,
Price: 10,
Attribute: {
Id: 1,
Price: 2,
Modifier: {
Id: 34,
Price: 33
}
}
};
function getPrices(obj, arr) {
$.each(obj, function(k, v) {
if (k == "Price")
arr.push(v);
else if (typeof(v) == 'object')
getPrices(obj[k], arr);
});
return arr;
}
var prices = getPrices(o, []);
console.log(prices);