<?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>WP Track &#187; Javascript</title>
	<atom:link href="http://www.wptrack.com/tag/javascript/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.wptrack.com</link>
	<description>Wordpress based solutions, themes and plugins</description>
	<lastBuildDate>Wed, 06 Apr 2011 15:23:26 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>JSON associative array &#8211; differences between Webkit and others</title>
		<link>http://www.wptrack.com/json-associative-array-differences-between-webkit-and-others/</link>
		<comments>http://www.wptrack.com/json-associative-array-differences-between-webkit-and-others/#comments</comments>
		<pubDate>Thu, 18 Mar 2010 11:15:34 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Javascript]]></category>
		<category><![CDATA[array]]></category>
		<category><![CDATA[json]]></category>

		<guid isPermaLink="false">http://www.wptrack.com/?p=6</guid>
		<description><![CDATA[Recently found very interesting and sad issue when processing JSON results
assume you have following associative array
var a = {{"5":"five"},{"4":"four"},{"3":"three"},{"2":"two"},{"1":"one"}}
now
for(var n in a){
document.write(i + " = " + a[i] + "&#60;br/&#62;") ;
}
Result in Firefox:
5 = five
4 = four
3 = three
2 = two
1 = one
looks correct
now run in Chrome
Result
1 = one
2 = two
3 = three
4 = four
5 [...]]]></description>
			<content:encoded><![CDATA[<p>Recently found very interesting and sad issue when processing JSON results</p>
<p>assume you have following associative array</p>
<blockquote><p>var a = {{"5":"five"},{"4":"four"},{"3":"three"},{"2":"two"},{"1":"one"}}</p></blockquote>
<p>now</p>
<blockquote><p>for(var n in a){<br />
document.write(i + " = " + a[i] + "&lt;br/&gt;") ;<br />
}</p></blockquote>
<p>Result in Firefox:</p>
<blockquote><p>5 = five<br />
4 = four<br />
3 = three<br />
2 = two<br />
1 = one</p></blockquote>
<p>looks correct</p>
<p>now run in Chrome<br />
Result</p>
<blockquote><p>1 = one<br />
2 = two<br />
3 = three<br />
4 = four<br />
5 = five</p></blockquote>
<p>Seem like Chrome autoconverted our associative array to numeric</p>
<p>just keep in in mind when processing such arrays. in my scenario it was when i was processing database results returned in jQuery.ajax and result was JSON associative array with IDs as keys. i have had to discard associative arrays and have regular.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.wptrack.com/json-associative-array-differences-between-webkit-and-others/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

