const A = [1,2,3];
const B = [4,5,6];
const C = [7,8,9];
const total = {A,B,C,D:{
id:1,
child:{
id:2,
name:'xx'
}
}};
function test(num){
for(let item in total){
if(total[item].includes(num))
return item
}
return 0
}
console.log(test(5))
function deepClone(object){
let cloneData;
if(Array.isArray(object)){
cloneData = [];
object.forEach(e=>{
cloneData.push(deepClone(e))
})
}else if(typeof object === 'object'){
cloneData = {};
for(let item in object){
cloneData[item] = object[deepClone(item)]
}
}else{
cloneData = object;
}
}
let num = 123;
let copytotal = deepClone(total)
console.log(total === copytotal)
console