<?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: Be careful with JavaScript variable declarations</title>
	<atom:link href="http://www.thunderguy.com/semicolon/2007/07/30/be-careful-with-javascript-variable-declarations/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.thunderguy.com/semicolon/2007/07/30/be-careful-with-javascript-variable-declarations/</link>
	<description>Software, the Internet and you.</description>
	<lastBuildDate>Tue, 16 Mar 2010 04:05:30 -0700</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.5</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: Software Evolution &#187; Blog Archive &#187; Be careful with JavaScript variable declarations</title>
		<link>http://www.thunderguy.com/semicolon/2007/07/30/be-careful-with-javascript-variable-declarations/comment-page-1/#comment-44178</link>
		<dc:creator>Software Evolution &#187; Blog Archive &#187; Be careful with JavaScript variable declarations</dc:creator>
		<pubDate>Tue, 22 Jan 2008 11:25:05 +0000</pubDate>
		<guid isPermaLink="false">http://www.thunderguy.com/semicolon/2007/07/30/be-careful-with-javascript-variable-declarations/#comment-44178</guid>
		<description>[...] More:  continued here  [...]</description>
		<content:encoded><![CDATA[<p>[...] More:  continued here  [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Bennett</title>
		<link>http://www.thunderguy.com/semicolon/2007/07/30/be-careful-with-javascript-variable-declarations/comment-page-1/#comment-37648</link>
		<dc:creator>Bennett</dc:creator>
		<pubDate>Tue, 18 Sep 2007 09:38:04 +0000</pubDate>
		<guid isPermaLink="false">http://www.thunderguy.com/semicolon/2007/07/30/be-careful-with-javascript-variable-declarations/#comment-37648</guid>
		<description>Well, of course this is mandatory in C and C++ since they make no such guarantees. I agree with you in the case of Java because it silently initialises variables to a plausible value (e.g. 0 for numeric variables) which might therefore be used by accident if you forget to initialise it properly.

But in dynamically-typed languages like JavaScript it makes less sense since variables are initialised to a special value (&lt;code&gt;undefined&lt;/code&gt;) -- if it gets used by accident then the error will be immediately obvious.

Having said that, it doesn&#039;t hurt to put &quot;&lt;code&gt;= 0&lt;/code&gt;&quot; or &quot;&lt;code&gt;= &quot;&quot;&lt;/code&gt;&quot;, does it?</description>
		<content:encoded><![CDATA[<p>Well, of course this is mandatory in C and C++ since they make no such guarantees. I agree with you in the case of Java because it silently initialises variables to a plausible value (e.g. 0 for numeric variables) which might therefore be used by accident if you forget to initialise it properly.</p>
<p>But in dynamically-typed languages like JavaScript it makes less sense since variables are initialised to a special value (<code>undefined</code>) &#8212; if it gets used by accident then the error will be immediately obvious.</p>
<p>Having said that, it doesn&#8217;t hurt to put &#8220;<code>= 0</code>&#8221; or &#8220;<code>= ""</code>&#8220;, does it?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Greg</title>
		<link>http://www.thunderguy.com/semicolon/2007/07/30/be-careful-with-javascript-variable-declarations/comment-page-1/#comment-37590</link>
		<dc:creator>Greg</dc:creator>
		<pubDate>Mon, 17 Sep 2007 13:07:54 +0000</pubDate>
		<guid isPermaLink="false">http://www.thunderguy.com/semicolon/2007/07/30/be-careful-with-javascript-variable-declarations/#comment-37590</guid>
		<description>Regardless of the guarantees that modern C, C++, and Java give about clearing memory when declaring a variable, it is always good practice to set a variable unconditionally before reading from it. This is as much for program readability as it is for avoiding problems like the case you bring up.</description>
		<content:encoded><![CDATA[<p>Regardless of the guarantees that modern C, C++, and Java give about clearing memory when declaring a variable, it is always good practice to set a variable unconditionally before reading from it. This is as much for program readability as it is for avoiding problems like the case you bring up.</p>
]]></content:encoded>
	</item>
</channel>
</rss>
