<?xml version="1.0" encoding="UTF-8"?><!-- generator="wordpress/2.2.2" -->
<rss version="2.0" 
	xmlns:content="http://purl.org/rss/1.0/modules/content/">
<channel>
	<title>Comments on: javascript arbitrarily decides it is not truly typeless</title>
	<link>http://krisgale.com/javascript-arbitrarily-decides-it-is-not-truly-typeless/</link>
	<description>meanderings of a computer scientist on the brink of sheer insanity.</description>
	<pubDate>Fri, 25 Jul 2008 02:45:48 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.2.2</generator>

	<item>
		<title>By: krisgale</title>
		<link>http://krisgale.com/javascript-arbitrarily-decides-it-is-not-truly-typeless/#comment-502</link>
		<author>krisgale</author>
		<pubDate>Thu, 31 Jan 2008 01:57:54 +0000</pubDate>
		<guid>http://krisgale.com/javascript-arbitrarily-decides-it-is-not-truly-typeless/#comment-502</guid>
		<description>hmm, i hadn't thought of === in that way but you're right. it's just that it's typical use is to ensure that you're comparing the actual contents of one string to another, not some evaluated representation of it ("03" == 3). i guess the only way to be 100% sure is to always use Object.toString() and === when comparing strings, or Object.valueOf() and == when comparing non-strings.</description>
		<content:encoded><![CDATA[<p>hmm, i hadn&#8217;t thought of === in that way but you&#8217;re right. it&#8217;s just that it&#8217;s typical use is to ensure that you&#8217;re comparing the actual contents of one string to another, not some evaluated representation of it (&#8221;03&#8243; == 3). i guess the only way to be 100% sure is to always use Object.toString() and === when comparing strings, or Object.valueOf() and == when comparing non-strings.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Jay Moiron</title>
		<link>http://krisgale.com/javascript-arbitrarily-decides-it-is-not-truly-typeless/#comment-501</link>
		<author>Jay Moiron</author>
		<pubDate>Thu, 31 Jan 2008 00:43:31 +0000</pubDate>
		<guid>http://krisgale.com/javascript-arbitrarily-decides-it-is-not-truly-typeless/#comment-501</guid>
		<description>Actually, JavaScript has types; they're just weak because there are some implicit conversion rules.  In this case, any use of binary + involving a string results in the string representation of each side being concatenated.  Firing up firebug quickly shows:

&#62;&#62;&#62; "10" + 5
"105"
&#62;&#62;&#62; 10 + "5"
"105"
&#62;&#62;&#62; 10 + 5
15

Not only that, but you're using ===, which is the "Strict Equals Operator", as opposed to the "Equals Operator".  EMCA-262 sections 11.9.3 and 11.9.6 spell out the specific differences between === and ==, but you can think of == as a "type coerced equivalence" and === as a "strongly typed equivalence":

http://www.ecma-international.org/publications/standards/Ecma-262.htm

Just as JavaScript will coax integers to strings to concatenate rather than add (I believe Perl will do this based on the order of the operands), it'll attempt to do a string compare between two objects if you use "==".

-- Jay</description>
		<content:encoded><![CDATA[<p>Actually, JavaScript has types; they&#8217;re just weak because there are some implicit conversion rules.  In this case, any use of binary + involving a string results in the string representation of each side being concatenated.  Firing up firebug quickly shows:</p>
<p>&gt;&gt;&gt; &#8220;10&#8243; + 5<br />
&#8220;105&#8243;<br />
&gt;&gt;&gt; 10 + &#8220;5&#8243;<br />
&#8220;105&#8243;<br />
&gt;&gt;&gt; 10 + 5<br />
15</p>
<p>Not only that, but you&#8217;re using ===, which is the &#8220;Strict Equals Operator&#8221;, as opposed to the &#8220;Equals Operator&#8221;.  EMCA-262 sections 11.9.3 and 11.9.6 spell out the specific differences between === and ==, but you can think of == as a &#8220;type coerced equivalence&#8221; and === as a &#8220;strongly typed equivalence&#8221;:</p>
<p><a href="http://www.ecma-international.org/publications/standards/Ecma-262.htm" rel="nofollow">http://www.ecma-international.org/publications/standards/Ecma-262.htm</a></p>
<p>Just as JavaScript will coax integers to strings to concatenate rather than add (I believe Perl will do this based on the order of the operands), it&#8217;ll attempt to do a string compare between two objects if you use &#8220;==&#8221;.</p>
<p>&#8211; Jay</p>
]]></content:encoded>
	</item>
</channel>
</rss>
