Answers for "javascript loop all depths recursive object"

0

javascript loop all depths recursive object

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;
};
Posted by: Guest on August-05-2021

Code answers related to "javascript loop all depths recursive object"

Code answers related to "Javascript"

Browse Popular Code Answers by Language