JSFiddle - React, Tailwind, and code Playground
JavaScript
o = {
a: 10,
b: [{
b1: 101,
b2: 201
}, {
b3: 102,
b4: 204
}],
c: [{
c1: 107,
c2: 209,
d: [{
d1: 109
}, {
d2: 402
}]
}]
}
function getValues(obj) {
var result = [];
for (var key in obj) {
if (obj.hasOwnProperty(key)) {
var curVal = obj[key];
if (typeof (curVal) === 'object') {
result = result.concat(getValues(curVal));
} else {
result.push(curVal);
}
}
}
return result;
}
console.log(getValues(o));
console.log(getValues(o).indexOf(101) !== -1);
console.log(getValues(o).indexOf('nosuchvalue') !== -1);