Return to Snippet

Revision: 43226
at March 19, 2011 17:45 by anagaiyahoocom


Initial Code
function lookdeep(obj){
    var A= [], tem;
    for(var p in obj){
        if(obj.hasOwnProperty(p)){
                tem= obj[p];
                if(tem && typeof tem=='object'){
                        A[A.length]= p+':{ '+arguments.callee(tem).join(', ')+'}';
                }
                else A[A.length]= [p+':'+tem.toString()];
        }
    }
    return A;
}

var O={a: 1, b: 2, c:{c1: 3, c2: 4, c3:{t:true, f:false}},d: 11};

var s=lookdeep(O).join('\n');

console.log(s);

//Will display
/* 
a:1
b:2
c:{ c1:3, c2:4, c3:{ t:true, f:false}}
d:11
*/

Initial URL


Initial Description


Initial Title
Get All Values in Nested Object Using Recursive Function

Initial Tags
javascript

Initial Language
JavaScript