📜  javascript循环所有深度递归对象 - Javascript代码示例

📅  最后修改于: 2022-03-11 15:04:15.303000             🧑  作者: Mango

代码示例1
var findObjectByLabel = function(obj, label) {
    if(obj.label === label) { return obj; }
    for(var i in obj) {
        if(obj.hasOwnProperty(i)){
            var foundLabel = findObjectByLabel(obj[i], label);
            if(foundLabel) { return foundLabel; }
        }
    }
    return null;
};