JSFiddle - React, Tailwind, and code Playground
by qustosh
JavaScript
//test object
var o = {
a:{
a:"secret",
c:"secret",
qwe: {
qwe:{
qwe:"secret"
}
}
},
b:"secret",
c: 123,
d: {
a:"secret"
},
e:{
c:"secret"
}
};
function check(o, search){
var all = [];
function deep(o, search, path){
var path = path || "";
var tempPath;
for(var val in o){
if(o[val] === search){
tempPath = path + "["+ "'" + val + "'" +"]";
all.push({
path: tempPath,
ob:o,
val:val
});
}
if($.type(o[val]) == "object"){
tempPath = path + "["+ "'" + val + "'" +"]";
arguments.callee(o[val], search, tempPath);
}
}
}
deep(o,search);
return all;
}
var a = check(o, "secret");
console.log(a);