<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	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/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Aaron As a Chimp &#187; variables</title>
	<atom:link href="http://sachimp.com/tag/variables/feed/" rel="self" type="application/rss+xml" />
	<link>http://sachimp.com</link>
	<description>with a typewriter</description>
	<lastBuildDate>Sat, 18 Jun 2011 15:26:24 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
		<item>
		<title>The many lives of JavaScript variables</title>
		<link>http://sachimp.com/2008/12/13/javascript-variables/</link>
		<comments>http://sachimp.com/2008/12/13/javascript-variables/#comments</comments>
		<pubDate>Sun, 14 Dec 2008 03:42:30 +0000</pubDate>
		<dc:creator>AaronAsAChimp</dc:creator>
				<category><![CDATA[Sachimp Labs]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[special characters]]></category>
		<category><![CDATA[variables]]></category>

		<guid isPermaLink="false">http://sachimp.com/?p=13</guid>
		<description><![CDATA[So, It was about three months ago when I first met jQuery.  It&#8217;s a neat little library that helps JavaScript programmers easily do relatively complex things.  Among many of its features one stood out to me.  The $() function is an interesting beast that takes a CSS selector or XPath and returns a set of [...]]]></description>
			<content:encoded><![CDATA[<!-- Start Shareaholic LikeButtonSetTop --><!-- End Shareaholic LikeButtonSetTop --><p>So, It was about three months ago when I first met jQuery.  It&#8217;s a neat little library that helps JavaScript programmers easily do relatively complex things.  Among many of its features one stood out to me.  The $() function is an interesting beast that takes a CSS selector or XPath and returns a set of matching nodes.  However, the application of it was not what attracted me to it.</p>
<h3>The Revelation</h3>
<p>The name, a single dollar sign, is what struck me.  I never knew that such a character could be used in a variable name.  As I, and many others, were taught the only character allowed were:</p>
<ol>
<li>letters</li>
<li>underscores</li>
<li>and numbers so long they are not the first character</li>
</ol>
<p>I was interested and decided to embark on quest to figure out what characters were allowed and which weren&#8217;t.  This took me to the <a href="http://www.ecma-international.org/publications/standards/Ecma-262.htm">ECMA-262 specification</a>, the standard for JavaScript, or ECMA Script as its formally called. The standard states:</p>
<blockquote><p>Identifiers are interpreted according to the grammar given in Section 5.16 of the upcoming version 3.0 of the Unicode standard, with some small modifications.</p></blockquote>
<p>The <a href="http://www.unicode.org/reports/tr31/">Unicode Standard</a> allows for nearly 14,000 characters to be used in variables, as opposed to the measly 63 that are commonly used.</p>
<h3>The Disappointment</h3>
<p>I instantly tried to stuff Sigmas (Σ) and Double Struck N&#8217;s (ℕ) in to my code, but to my dismay, they didn&#8217;t work.  Disappointing? Yes.  Surprising? No.  It seems to be this way with all web standard&#8217;s, either implemented wrongly or incompletely (or both, heres looking at you Microsoft).  So, to test compliance I wrote a small JavaScript that creates a variable, using one of the Unicode characters, and assigns a value to it.  If throws an exception, then that means the browser doesn&#8217;t support that character.  Simple enough, but who wins this browser compliance battle.  So far Opera, it supports 99.5% of all characters.  Heres the data I&#8217;ve collected so far:</p>
<table border="0">
<thead>
<tr>
<td>Browser</td>
<td>Chars Tested</td>
<td>Non Supported Chars</td>
<td>% Not Supported</td>
</tr>
</thead>
<tbody>
<tr>
<td><strong>Opera 9.27<br />
</strong>(Ubuntu Linux)</td>
<td>13935</td>
<td>78</td>
<td>0.5597416576964478</td>
</tr>
<tr>
<td><strong>Opera 9.63<br />
</strong>(Windows XP &amp; Ubuntu Linux)</td>
<td>13935</td>
<td>80</td>
<td>0.5740940078937926</td>
</tr>
<tr>
<td><strong>Internet Explorer 8<br />
</strong>(Windows 7 and XP)</td>
<td>13935</td>
<td>2131</td>
<td>15.292429135270902</td>
</tr>
<tr>
<td><strong>Google Chrome<br />
</strong>(Windows XP)</td>
<td>13935</td>
<td>2746</td>
<td>19.705776820954434</td>
</tr>
<tr>
<td><strong>Internet Explorer 7 &amp; 6<br />
</strong>(Windows XP)</td>
<td>13935</td>
<td>4340</td>
<td>31.144599928238246</td>
</tr>
<tr>
<td><strong>Firefox 3.0, 3.5, 3.6<br />
</strong>(Windows XP &amp; Ubuntu Linux)</td>
<td>13935</td>
<td>7220</td>
<td>51.811984212414785</td>
</tr>
</tbody>
</table>
<p>Yeah, I know thats a pathetically small dataset, but you can help run <a title="READ THE WARNING FIRST" href="http://sachimp.com/labs/unicode-support.html">the test script</a> and then post the last three lines in the comments along with the browser, version, and OS.  WARNING: This script takes a very long time to execute, it may appear to lock your browser up, but be patient.</p>
<p>On an unrelated note, Chrome&#8217;s Javascript engine was suprisingly fast.</p>
<div class="shr-publisher-13"></div><!-- Start Shareaholic LikeButtonSetBottom --><div style="clear: both; min-height: 1px; height: 3px; width: 100%;"></div><div class='shareaholic-like-buttonset' style='float:none;height:30px;'><a class='shareaholic-fblike' data-shr_layout='button_count' data-shr_showfaces='false' data-shr_href='http%3A%2F%2Fsachimp.com%2F2008%2F12%2F13%2Fjavascript-variables%2F' data-shr_title='The+many+lives+of+JavaScript+variables'></a><a class='shareaholic-googleplusone' data-shr_size='medium' data-shr_count='true' data-shr_href='http%3A%2F%2Fsachimp.com%2F2008%2F12%2F13%2Fjavascript-variables%2F' data-shr_title='The+many+lives+of+JavaScript+variables'></a></div><div style="clear: both; min-height: 1px; height: 3px; width: 100%;"></div><!-- End Shareaholic LikeButtonSetBottom -->]]></content:encoded>
			<wfw:commentRss>http://sachimp.com/2008/12/13/javascript-variables/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

