美文网首页
递归对象属性

递归对象属性

作者: ilaoke | 来源:发表于2017-08-30 13:58 被阅读42次

    https://stackoverflow.com/questions/12295494/jquery-how-to-recursively-loop-over-an-objects-nested-properties

    function recursiveIteration(object) {
        for (var property in object) {
            if (object.hasOwnProperty(property)) {
                if (typeof object[property] == "object"){
                    recursiveIteration(object[property]);
                }else{
                    //found a property which is not an object, check for your conditions here
                }
            }
        }
    }
    

    相关文章

      网友评论

          本文标题:递归对象属性

          本文链接:https://www.haomeiwen.com/subject/hcjtjxtx.html