Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>If won't to use stringify you can reproduce it, like this:</p> <p><code>OBJtoString(object [,n])</code> accempt 2 args:</p> <ul> <li><code>object</code> (needed) the object you need to log (in my release array and object is the same)</li> <li><p><code>n</code> numbero of space that indent every new line inside object aruments.</p> <pre><code>var OBJtoString = function(_o,_m,_rf,_dep,_res){ _dep = [], _rf = function(obj,n,_n,_a,_k,_i,_ws,_f,_e){ if(typeof obj != "object") return false; if(typeof _a === "undefined") _a = "FIRST PARENT OBJECT"; _dep.push(obj), _f = (_dep.length &lt; 1) ? function(){} : function(_z,_x){ for(_x = 0; _x &lt;= _dep.length; _x++){ if(obj[_z] == _dep[_x]) return true; } return false; } _ws = ""; if(typeof n === "undefined") n = 1; if(typeof _n === "undefined") _n = n; for(_k = 0; _k &lt;= n; _k++){ _ws += " "; } var response ="{ \n"; for(var _i in obj){ if(typeof obj[_i] !== "object"){ if(typeof obj[_i] === "string") obj[_i] = "'"+obj[_i].toString()+"'"; if(typeof obj[_i] === "boolean") obj[_i] = obj[_i].toString() + " (boolean)"; response += _ws + _i + " : " + obj[_i].toString(); response += "\n"; continue; } response += (_f(_i)) ? _ws + _i + " : "+ _a +" (prevent loop)\n" : _ws + _i + " : " + _rf(obj[_i],n+_n,_n,_a); } if(_n != n) response += _ws; return response +="} \n"; } _res = _rf(_o,_m); _dep = []; return _res; } </code></pre></li> </ul> <h3>Uses Example:</h3> <pre><code>var example = {ciao : "hellow", saluto : {ciao : "ciao", dam : true}}; example.parentObj = example; console.log(OBJtoString(example,4)); </code></pre> <h3>return:</h3> <pre><code> { ciao : 'hellow' saluto : { ciao : 'ciao' dam : true (boolean) } parentObj : FIRST PARENT OBJECT (prevent loop) } </code></pre> <h3>Other Example:</h3> <pre><code>var example = {ciao : "hellow", saluto : {ciao : "ciao", dam : true}}; example.parentObj = example; example.f = { g : example } console.log(OBJtoString(example,4)); </code></pre> <h3>Return:</h3> <pre><code>{ ciao : 'hellow' saluto : { ciao : 'ciao' dam : true (boolean) } parentObj : FIRST PARENT OBJECT (prevent loop) f : { g : FIRST PARENT OBJECT (prevent loop) } } </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload