<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0" xml:base="http://jennyandlih.com" xmlns:dc="http://purl.org/dc/elements/1.1/">
<channel>
 <title>JavaScript</title>
 <link>http://jennyandlih.com/note-type/tech/javascript</link>
 <description>The taxonomy view.</description>
 <language>en</language>
<item>
 <title>Resolved: Logging to Firebug console breaks IE</title>
 <link>http://jennyandlih.com/resolved-logging-firebug-console-breaks-ie</link>
 <description>&lt;p&gt;The firebug console is great for debugging javascript -- but it&#039;s &lt;b&gt;really&lt;/b&gt; annoying when you want to quickly check something in IE and can&#039;t without first removing all your debug statements to avoid a bunch of javascript errors.&lt;/p&gt;
&lt;p&gt;Here&#039;s a handy log function which checks first that firebug is in use before trying to log to the console.  The function is a no-op in IE.&lt;/p&gt;
&lt;p&gt;&lt;div class=&quot;codeblock&quot;&gt;&lt;code&gt;log_debug = function() {&lt;br /&gt;&amp;nbsp; if(window.console &amp;amp;&amp;amp; window.console.firebug) console.log.apply(this, arguments)&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;log_debug(&amp;#039;foo&amp;#039;, &amp;#039;bar&amp;#039;, &amp;#039;bash&amp;#039;)&lt;/code&gt;&lt;/div&gt;&lt;/p&gt;
</description>
 <comments>http://jennyandlih.com/resolved-logging-firebug-console-breaks-ie#comments</comments>
 <category domain="http://jennyandlih.com/note-type/tech/firefox">firefox</category>
 <category domain="http://jennyandlih.com/note-type/tech/javascript">JavaScript</category>
 <category domain="http://jennyandlih.com/note-type/tech/jquery">jQuery</category>
 <category domain="http://jennyandlih.com/note-type/tech/windoze">Windoze</category>
 <pubDate>Sat, 07 Jun 2008 18:05:15 -0600</pubDate>
 <dc:creator>jenny</dc:creator>
 <guid isPermaLink="false">652 at http://jennyandlih.com</guid>
</item>
<item>
 <title>Declaring and initializing arrays</title>
 <link>http://jennyandlih.com/declaring-and-initializing-arrays</link>
 <description>&lt;p&gt;These are identical declarations for an array:&lt;br /&gt;
&lt;div class=&quot;codeblock&quot;&gt;&lt;code&gt;var foo = new Array()&lt;br /&gt;var bar = []&lt;/code&gt;&lt;/div&gt;&lt;/p&gt;
&lt;p&gt;...as are these, which also initialize the array:&lt;br /&gt;
&lt;div class=&quot;codeblock&quot;&gt;&lt;code&gt;var foo = new Array(&amp;#039;first&amp;#039;, &amp;#039;second&amp;#039;, &amp;#039;third&amp;#039;)&lt;br /&gt;var bar = [&amp;#039;first&amp;#039;, &amp;#039;second&amp;#039;, &amp;#039;third&amp;#039;]&lt;/code&gt;&lt;/div&gt;&lt;/p&gt;
&lt;p&gt;Both of the above are accessed like so:&lt;br /&gt;
&lt;div class=&quot;codeblock&quot;&gt;&lt;code&gt;alert(foo[0])&amp;nbsp; // alerts &amp;#039;first&amp;#039;&lt;br /&gt;alert(bar[0])&amp;nbsp; // alerts &amp;#039;first&amp;#039;&lt;/code&gt;&lt;/div&gt;&lt;/p&gt;
&lt;p&gt;An associative array (which is really an object in JS) is declared/initialized like so:&lt;br /&gt;
&lt;div class=&quot;codeblock&quot;&gt;&lt;code&gt;var bash = {&lt;br /&gt;&amp;nbsp; first : &amp;#039;value 1&amp;#039;,&lt;br /&gt;&amp;nbsp; second: &amp;#039;value 2&amp;#039;,&lt;br /&gt;&amp;nbsp; third : &amp;#039;value 3&amp;#039;&lt;br /&gt;}&lt;/code&gt;&lt;/div&gt;&lt;/p&gt;
&lt;p&gt;&lt;a href=&quot;http://jennyandlih.com/declaring-and-initializing-arrays&quot;&gt;read more&lt;/a&gt;&lt;/p&gt;</description>
 <comments>http://jennyandlih.com/declaring-and-initializing-arrays#comments</comments>
 <category domain="http://jennyandlih.com/note-type/tech/javascript">JavaScript</category>
 <pubDate>Sun, 16 Mar 2008 19:59:26 -0600</pubDate>
 <dc:creator>jenny</dc:creator>
 <guid isPermaLink="false">490 at http://jennyandlih.com</guid>
</item>
<item>
 <title>Global and Local variables in JavaScript</title>
 <link>http://jennyandlih.com/global-and-local-variables-javascript</link>
 <description>&lt;p&gt;Any variable that is initialized inside a function using the &lt;code&gt;var&lt;/code&gt; keyword will have a local scope. If a variable is initialized inside a function without &lt;code&gt;var&lt;/code&gt;, it will have a global scope. A local variable can have the same name as a global variable.&lt;/p&gt;
</description>
 <comments>http://jennyandlih.com/global-and-local-variables-javascript#comments</comments>
 <category domain="http://jennyandlih.com/note-type/tech/javascript">JavaScript</category>
 <pubDate>Mon, 17 Dec 2007 01:29:05 -0700</pubDate>
 <dc:creator>jenny</dc:creator>
 <guid isPermaLink="false">359 at http://jennyandlih.com</guid>
</item>
</channel>
</rss>

