<?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"
	>
<channel>
	<title>Comments on: How to avoid automatic type conversion in JavaScript</title>
	<atom:link href="http://www.robertnyman.com/2008/05/16/how-to-avoid-automatic-type-conversion-in-javascript/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.robertnyman.com/2008/05/16/how-to-avoid-automatic-type-conversion-in-javascript/</link>
	<description>Web development and Internet trends</description>
	<pubDate>Thu, 20 Nov 2008 10:53:59 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.6.1</generator>
		<item>
		<title>By: Robert Nyman</title>
		<link>http://www.robertnyman.com/2008/05/16/how-to-avoid-automatic-type-conversion-in-javascript/#comment-277056</link>
		<dc:creator>Robert Nyman</dc:creator>
		<pubDate>Mon, 19 May 2008 07:55:25 +0000</pubDate>
		<guid isPermaLink="false">http://www.robertnyman.com/2008/05/16/how-to-avoid-automatic-type-conversion-in-javascript/#comment-277056</guid>
		<description>Stefan,

Yes, it's a great thing to avoid all those weird errors.

Berserk,

Granted, type checking by default would have been nice, although it's looseness has also made it extremely flexible. I guess it's all about doing the best you can with the tools at hand.</description>
		<content:encoded><![CDATA[<p>Stefan,</p>
<p>Yes, it&#8217;s a great thing to avoid all those weird errors.</p>
<p>Berserk,</p>
<p>Granted, type checking by default would have been nice, although it&#8217;s looseness has also made it extremely flexible. I guess it&#8217;s all about doing the best you can with the tools at hand.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Berserk</title>
		<link>http://www.robertnyman.com/2008/05/16/how-to-avoid-automatic-type-conversion-in-javascript/#comment-275570</link>
		<dc:creator>Berserk</dc:creator>
		<pubDate>Sat, 17 May 2008 09:53:21 +0000</pubDate>
		<guid isPermaLink="false">http://www.robertnyman.com/2008/05/16/how-to-avoid-automatic-type-conversion-in-javascript/#comment-275570</guid>
		<description>One of the causes, as in Andrea's example, is that the same operator is used for addition and concatenation. I find Perl's .-operator much smarter is this kind of circumstances. Of course, in some ways, concatenation can be seen as addition for strings so it makes sense in a semantic way, I guess.</description>
		<content:encoded><![CDATA[<p>One of the causes, as in Andrea&#8217;s example, is that the same operator is used for addition and concatenation. I find Perl&#8217;s .-operator much smarter is this kind of circumstances. Of course, in some ways, concatenation can be seen as addition for strings so it makes sense in a semantic way, I guess.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Stefan Van Reeth</title>
		<link>http://www.robertnyman.com/2008/05/16/how-to-avoid-automatic-type-conversion-in-javascript/#comment-275092</link>
		<dc:creator>Stefan Van Reeth</dc:creator>
		<pubDate>Fri, 16 May 2008 21:21:12 +0000</pubDate>
		<guid isPermaLink="false">http://www.robertnyman.com/2008/05/16/how-to-avoid-automatic-type-conversion-in-javascript/#comment-275092</guid>
		<description>Since I use JSLint I have no choice but using ===. Which is a good thing. In fact I only used == before reading a similiar post somewhere, and that's now allready a moment far away in the cold mists of time....

Admitted, before that day sometimes I pulled my hairs wondering "wtf". Eternal thx to whoever pointed it out then, and good work Robert on spreading the word.

In short: === rocks. Back to the beer ;)</description>
		<content:encoded><![CDATA[<p>Since I use JSLint I have no choice but using ===. Which is a good thing. In fact I only used == before reading a similiar post somewhere, and that&#8217;s now allready a moment far away in the cold mists of time&#8230;.</p>
<p>Admitted, before that day sometimes I pulled my hairs wondering &#8220;wtf&#8221;. Eternal thx to whoever pointed it out then, and good work Robert on spreading the word.</p>
<p>In short: === rocks. Back to the beer <img src='http://www.robertnyman.com/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Robert Nyman</title>
		<link>http://www.robertnyman.com/2008/05/16/how-to-avoid-automatic-type-conversion-in-javascript/#comment-274872</link>
		<dc:creator>Robert Nyman</dc:creator>
		<pubDate>Fri, 16 May 2008 15:23:37 +0000</pubDate>
		<guid isPermaLink="false">http://www.robertnyman.com/2008/05/16/how-to-avoid-automatic-type-conversion-in-javascript/#comment-274872</guid>
		<description>Glad to help!

Andrea, Dave,

Those are just wonderful! :-)
Thanks for pointing them out.

Dave,

Thanks!</description>
		<content:encoded><![CDATA[<p>Glad to help!</p>
<p>Andrea, Dave,</p>
<p>Those are just wonderful! <img src='http://www.robertnyman.com/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /><br />
Thanks for pointing them out.</p>
<p>Dave,</p>
<p>Thanks!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Dave</title>
		<link>http://www.robertnyman.com/2008/05/16/how-to-avoid-automatic-type-conversion-in-javascript/#comment-274701</link>
		<dc:creator>Dave</dc:creator>
		<pubDate>Fri, 16 May 2008 10:10:12 +0000</pubDate>
		<guid isPermaLink="false">http://www.robertnyman.com/2008/05/16/how-to-avoid-automatic-type-conversion-in-javascript/#comment-274701</guid>
		<description>Can you guess what this equates to:
&lt;code&gt;alert('2' * '2' + 1 + '3' + 7);&lt;/code&gt;
The * converts strings to ints, then the + is used as addition. The '3' means the 2nd + is concatenate, turning it into a string, so the final + 7 is also concatenate. As always, be careful getting ints from the user, and be careful with +. Similar problems in PHP too.

PS, Comment preview is very cool.</description>
		<content:encoded><![CDATA[<p>Can you guess what this equates to:<br />
<code>alert('2' * '2' + 1 + '3' + 7);</code><br />
The * converts strings to ints, then the + is used as addition. The &#8216;3&#8242; means the 2nd + is concatenate, turning it into a string, so the final + 7 is also concatenate. As always, be careful getting ints from the user, and be careful with +. Similar problems in <acronym title="Hypertext PreProcessing">PHP</acronym> too.</p>
<p>PS, Comment preview is very cool.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Andrea Giammarchi</title>
		<link>http://www.robertnyman.com/2008/05/16/how-to-avoid-automatic-type-conversion-in-javascript/#comment-274639</link>
		<dc:creator>Andrea Giammarchi</dc:creator>
		<pubDate>Fri, 16 May 2008 08:25:38 +0000</pubDate>
		<guid isPermaLink="false">http://www.robertnyman.com/2008/05/16/how-to-avoid-automatic-type-conversion-in-javascript/#comment-274639</guid>
		<description>My favorite one is this one:
&lt;code&gt;
alert({toString:function(){return "null"}} == "null");
&lt;/code&gt;
;)</description>
		<content:encoded><![CDATA[<p>My favorite one is this one:<br />
<code><br />
alert({toString:function(){return "null"}} == "null");<br />
</code><br />
 <img src='http://www.robertnyman.com/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Anthony</title>
		<link>http://www.robertnyman.com/2008/05/16/how-to-avoid-automatic-type-conversion-in-javascript/#comment-274634</link>
		<dc:creator>Anthony</dc:creator>
		<pubDate>Fri, 16 May 2008 08:16:37 +0000</pubDate>
		<guid isPermaLink="false">http://www.robertnyman.com/2008/05/16/how-to-avoid-automatic-type-conversion-in-javascript/#comment-274634</guid>
		<description>It is indeed a very common problem, which most of the developers I have encountered are sadly not aware of...
I tend to "validate" my javascript code with JSLint on a regular basis, and it has already helped me prevent and/or correct a few bugs. Once you know how to configure it, it is really helpful.

Thanks for the reminder Robert, I haven't checked my code with JSLint in a while ;-)</description>
		<content:encoded><![CDATA[<p>It is indeed a very common problem, which most of the developers I have encountered are sadly not aware of&#8230;<br />
I tend to &#8220;validate&#8221; my javascript code with JSLint on a regular basis, and it has already helped me prevent and/or correct a few bugs. Once you know how to configure it, it is really helpful.</p>
<p>Thanks for the reminder Robert, I haven&#8217;t checked my code with JSLint in a while <img src='http://www.robertnyman.com/wp-includes/images/smilies/icon_wink.gif' alt=';-)' class='wp-smiley' /></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Phil Nash</title>
		<link>http://www.robertnyman.com/2008/05/16/how-to-avoid-automatic-type-conversion-in-javascript/#comment-274630</link>
		<dc:creator>Phil Nash</dc:creator>
		<pubDate>Fri, 16 May 2008 08:11:59 +0000</pubDate>
		<guid isPermaLink="false">http://www.robertnyman.com/2008/05/16/how-to-avoid-automatic-type-conversion-in-javascript/#comment-274630</guid>
		<description>Loose typing is one of my favourite things in JavaScript (and any other language I can find it in). Maybe because I expect things to be loose (yeah, you should see me try to program in Java) I don't tend to have problems with them.

Good tip though! If this does present a problem, I'll know what to do.</description>
		<content:encoded><![CDATA[<p>Loose typing is one of my favourite things in JavaScript (and any other language I can find it in). Maybe because I expect things to be loose (yeah, you should see me try to program in Java) I don&#8217;t tend to have problems with them.</p>
<p>Good tip though! If this does present a problem, I&#8217;ll know what to do.</p>
]]></content:encoded>
	</item>
</channel>
</rss>
