I am trying to generate an object literal string from an object. I know I can myself create a function to do this with something like:
//pseudocode
function getOL(object){
for(var prop in object){
if(!object.hasOwnProperty(prop)){return;}
else if (typeof var === object){/*recur*/}
//case function
//case string
}
}
However, this method seems pretty grossly inefficient. Even if there isn't a native function, which is what seems like is the case, is there some alternative way to write this that is more efficient than recursively looping over every property of an object and its children?
console.debug().JSON.stringifymay work to an extent. It even accepts arguments to control indentation.