<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: JavaScript print_r() or var_dump() Equivalent</title>
	<atom:link href="http://scriptnode.com/article/javascript-print_r-or-var_dump-equivalent/feed/" rel="self" type="application/rss+xml" />
	<link>http://scriptnode.com/article/javascript-print_r-or-var_dump-equivalent/</link>
	<description>Tips and tricks for web developers.</description>
	<lastBuildDate>Sat, 14 Nov 2009 18:04:15 -0800</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.4</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: Maskull</title>
		<link>http://scriptnode.com/article/javascript-print_r-or-var_dump-equivalent/comment-page-1/#comment-314</link>
		<dc:creator>Maskull</dc:creator>
		<pubDate>Sun, 13 Sep 2009 18:01:31 +0000</pubDate>
		<guid isPermaLink="false">http://scriptnode.com/?p=34#comment-314</guid>
		<description>one of the nicest and cleanest web page layouts I&#039;ve seen on the net. great stuff!</description>
		<content:encoded><![CDATA[<p>one of the nicest and cleanest web page layouts I&#8217;ve seen on the net. great stuff!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: dProphet</title>
		<link>http://scriptnode.com/article/javascript-print_r-or-var_dump-equivalent/comment-page-1/#comment-305</link>
		<dc:creator>dProphet</dc:creator>
		<pubDate>Tue, 11 Aug 2009 00:36:23 +0000</pubDate>
		<guid isPermaLink="false">http://scriptnode.com/?p=34#comment-305</guid>
		<description>Sorry about the formatting above. Tried the pre tag, but it didn&#039;t work. You can see my version of the function properly formatted in the Digital Prophets pingback.

Thanks...</description>
		<content:encoded><![CDATA[<p>Sorry about the formatting above. Tried the pre tag, but it didn&#8217;t work. You can see my version of the function properly formatted in the Digital Prophets pingback.</p>
<p>Thanks&#8230;</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: ..:: Digital Prophets ::.. &#187; Recursive Object Traversal in Javascript (like PHP&#8217;s print_r&#8230;)</title>
		<link>http://scriptnode.com/article/javascript-print_r-or-var_dump-equivalent/comment-page-1/#comment-304</link>
		<dc:creator>..:: Digital Prophets ::.. &#187; Recursive Object Traversal in Javascript (like PHP&#8217;s print_r&#8230;)</dc:creator>
		<pubDate>Mon, 10 Aug 2009 23:25:15 +0000</pubDate>
		<guid isPermaLink="false">http://scriptnode.com/?p=34#comment-304</guid>
		<description>[...] use the following function, based on a script by Matt Hackett, in the console window of the IE8 Developer Tools to quickly inspect any object currently in scope [...]</description>
		<content:encoded><![CDATA[<p>[...] use the following function, based on a script by Matt Hackett, in the console window of the IE8 Developer Tools to quickly inspect any object currently in scope [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: dProphet</title>
		<link>http://scriptnode.com/article/javascript-print_r-or-var_dump-equivalent/comment-page-1/#comment-303</link>
		<dc:creator>dProphet</dc:creator>
		<pubDate>Mon, 10 Aug 2009 21:31:57 +0000</pubDate>
		<guid isPermaLink="false">http://scriptnode.com/?p=34#comment-303</guid>
		<description>Hi,

Thanks for the starting point. I wanted a version that could skip printing out long strings (innerHTML/outerHTML) as well as functions. I&#039;ve refactored your code to accomplish this. The new arguments are sMax and skipFunction. Strings will be truncated to sMax characters and functions will not be listed at all if skipFunction is true. I also show the depth of recursion at each new object, as well as string lengths prior to truncating. Hope somebody else finds it useful...

--dP


function print_r(x, max, sMax, skipFunction, sep, l) {
    max = max &#124;&#124; 10;
    sMax = sMax &#124;&#124; 25;
    skipFunction = skipFunction &#124;&#124; true;
    sep = sep &#124;&#124; &#039;  &#039;;
    l = l &#124;&#124; 0;
    if (l &gt; max) return &quot;[Stopped at &quot; + l + &quot; levels]\n&quot;;
    var i, r = &#039;&#039;, t = typeof x, tab = &#039;&#039;;
    if (x === null)
        r += &quot;(null)\n&quot;;
    else if (t == &#039;object&#039;) {
        l++;
        for (i = 0; i  sMax)
                x = x.substr(0, sMax) + &#039;...&#039;;
        }
        if (!(t == &#039;function&#039; &amp;&amp; skipFunction)) 
            r += &#039;(&#039; + t + slen + &#039;) &#039; + x + &quot;\n&quot;;
    }
    return r;
}
</description>
		<content:encoded><![CDATA[<p>Hi,</p>
<p>Thanks for the starting point. I wanted a version that could skip printing out long strings (innerHTML/outerHTML) as well as functions. I&#8217;ve refactored your code to accomplish this. The new arguments are sMax and skipFunction. Strings will be truncated to sMax characters and functions will not be listed at all if skipFunction is true. I also show the depth of recursion at each new object, as well as string lengths prior to truncating. Hope somebody else finds it useful&#8230;</p>
<p>&#8211;dP</p>
<p>function print_r(x, max, sMax, skipFunction, sep, l) {<br />
    max = max || 10;<br />
    sMax = sMax || 25;<br />
    skipFunction = skipFunction || true;<br />
    sep = sep || &#8216;  &#8216;;<br />
    l = l || 0;<br />
    if (l &gt; max) return &#8220;[Stopped at " + l + " levels]\n&#8221;;<br />
    var i, r = &#8221;, t = typeof x, tab = &#8221;;<br />
    if (x === null)<br />
        r += &#8220;(null)\n&#8221;;<br />
    else if (t == &#8216;object&#8217;) {<br />
        l++;<br />
        for (i = 0; i  sMax)<br />
                x = x.substr(0, sMax) + &#8216;&#8230;&#8217;;<br />
        }<br />
        if (!(t == &#8216;function&#8217; &amp;&amp; skipFunction))<br />
            r += &#8216;(&#8217; + t + slen + &#8216;) &#8216; + x + &#8220;\n&#8221;;<br />
    }<br />
    return r;<br />
}</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: jQuery debug plugin - print_r style output &#124; ProDevTips - dev notes and tutorials</title>
		<link>http://scriptnode.com/article/javascript-print_r-or-var_dump-equivalent/comment-page-1/#comment-301</link>
		<dc:creator>jQuery debug plugin - print_r style output &#124; ProDevTips - dev notes and tutorials</dc:creator>
		<pubDate>Sat, 11 Jul 2009 11:16:18 +0000</pubDate>
		<guid isPermaLink="false">http://scriptnode.com/?p=34#comment-301</guid>
		<description>[...] writing this piece I had to search for the two above articles and then I found another piece detailing yet another print_r clone. There I also learned about Firebug&#8217;s console.log(). Due [...]</description>
		<content:encoded><![CDATA[<p>[...] writing this piece I had to search for the two above articles and then I found another piece detailing yet another print_r clone. There I also learned about Firebug&#8217;s console.log(). Due [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Binny V A</title>
		<link>http://scriptnode.com/article/javascript-print_r-or-var_dump-equivalent/comment-page-1/#comment-263</link>
		<dc:creator>Binny V A</dc:creator>
		<pubDate>Sat, 03 Jan 2009 17:30:28 +0000</pubDate>
		<guid isPermaLink="false">http://scriptnode.com/?p=34#comment-263</guid>
		<description>Another implementation of the same thing - &lt;a href=&quot;http://www.openjs.com/scripts/others/dump_function_php_print_r.php&quot; rel=&quot;nofollow&quot;&gt;Javascript equivalent of PHP&#039;s print_r() function&lt;/a&gt;.</description>
		<content:encoded><![CDATA[<p>Another implementation of the same thing &#8211; <a href="http://www.openjs.com/scripts/others/dump_function_php_print_r.php" rel="nofollow">Javascript equivalent of PHP&#8217;s print_r() function</a>.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: B T &#187; Blog Archive &#187; JavaScript print_r() or var_dump() Equivalent</title>
		<link>http://scriptnode.com/article/javascript-print_r-or-var_dump-equivalent/comment-page-1/#comment-13</link>
		<dc:creator>B T &#187; Blog Archive &#187; JavaScript print_r() or var_dump() Equivalent</dc:creator>
		<pubDate>Thu, 03 Jul 2008 22:25:19 +0000</pubDate>
		<guid isPermaLink="false">http://scriptnode.com/?p=34#comment-13</guid>
		<description>[...] JavaScript print_r() or var_dump() Equivalent var myVar = { key1 : ‘value1′, key2 : ‘value2′, key3 : [&#039;a&#039;, &#039;b&#039;, &#039;c&#039;] }; try { console.log(’myVar: ‘, myVar); } catch(e) { alert(”You don’t have Firebug!nFor shame…”); }. Run this example. I think a large majority of webdevs use both &#8230; [...]</description>
		<content:encoded><![CDATA[<p>[...] JavaScript print_r() or var_dump() Equivalent var myVar = { key1 : ‘value1′, key2 : ‘value2′, key3 : ['a', 'b', 'c'] }; try { console.log(’myVar: ‘, myVar); } catch(e) { alert(”You don’t have Firebug!nFor shame…”); }. Run this example. I think a large majority of webdevs use both &#8230; [...]</p>
]]></content:encoded>
	</item>
</channel>
</rss>
