JavaScript function to get an object literal string
<p>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:</p>

<pre><code>//pseudocode
function getOL(object){
  for(var prop in object){
    if(!object.hasOwnProperty(prop)){return;}
    else if (typeof var === object){/*recur*/}
    //case function
    //case string
  }
}
</code></pre>

<p>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? </p>
