<?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: Javascript addEventListener &#8211; peculiarity or bug?</title>
	<atom:link href="http://alexlittle.net/blog/2007/09/11/javascript-addeventlistener-peculiarity-or-bug/feed/" rel="self" type="application/rss+xml" />
	<link>http://alexlittle.net/blog/2007/09/11/javascript-addeventlistener-peculiarity-or-bug/</link>
	<description></description>
	<lastBuildDate>Mon, 21 May 2012 14:06:17 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.2</generator>
	<item>
		<title>By: zahlenzerkleinerer &#187; Blog Archive &#187; JavaScript addEventListener im for loop</title>
		<link>http://alexlittle.net/blog/2007/09/11/javascript-addeventlistener-peculiarity-or-bug/comment-page-1/#comment-2277</link>
		<dc:creator>zahlenzerkleinerer &#187; Blog Archive &#187; JavaScript addEventListener im for loop</dc:creator>
		<pubDate>Sat, 24 Jan 2009 11:43:09 +0000</pubDate>
		<guid isPermaLink="false">http://alexlittle.net/blog/2007/09/11/javascript-addeventlistener-peculiarity-or-bug/#comment-2277</guid>
		<description>[...] das Objekt zu schauen der den Event ausgel&#246;st hat, gelang nicht auf den ersten Blick. Bis ich folgende L&#246;sung im Netz gefunden habe, es lohnt sich sehr oft eine Nacht &#252;ber dem Problem schalfen zu gehen. for (var [...]</description>
		<content:encoded><![CDATA[<p>[...] das Objekt zu schauen der den Event ausgel&#246;st hat, gelang nicht auf den ersten Blick. Bis ich folgende L&#246;sung im Netz gefunden habe, es lohnt sich sehr oft eine Nacht &#252;ber dem Problem schalfen zu gehen. for (var [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Rick</title>
		<link>http://alexlittle.net/blog/2007/09/11/javascript-addeventlistener-peculiarity-or-bug/comment-page-1/#comment-1153</link>
		<dc:creator>Rick</dc:creator>
		<pubDate>Wed, 16 Jul 2008 20:16:11 +0000</pubDate>
		<guid isPermaLink="false">http://alexlittle.net/blog/2007/09/11/javascript-addeventlistener-peculiarity-or-bug/#comment-1153</guid>
		<description>I just ran across this post while searching for something else.

What you&#039;re seeing in the first example is that you&#039;re referencing the loop variable i from your anonymous function.  Once the function is executed (*after* termination of the loop), the value is 10.  So whenever the event listener is triggered, it gets the value of i existing at that time, and passes it to test().

Java or other strongly-typed language would complain about referencing a local variable in an anonymous context.</description>
		<content:encoded><![CDATA[<p>I just ran across this post while searching for something else.</p>
<p>What you&#8217;re seeing in the first example is that you&#8217;re referencing the loop variable i from your anonymous function.  Once the function is executed (*after* termination of the loop), the value is 10.  So whenever the event listener is triggered, it gets the value of i existing at that time, and passes it to test().</p>
<p>Java or other strongly-typed language would complain about referencing a local variable in an anonymous context.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: a.little</title>
		<link>http://alexlittle.net/blog/2007/09/11/javascript-addeventlistener-peculiarity-or-bug/comment-page-1/#comment-71</link>
		<dc:creator>a.little</dc:creator>
		<pubDate>Fri, 21 Sep 2007 15:24:59 +0000</pubDate>
		<guid isPermaLink="false">http://alexlittle.net/blog/2007/09/11/javascript-addeventlistener-peculiarity-or-bug/#comment-71</guid>
		<description>Hi, Cheers, yes it does look like it&#039;s doing something like that, was just a bit of an unexpected result to me!</description>
		<content:encoded><![CDATA[<p>Hi, Cheers, yes it does look like it&#8217;s doing something like that, was just a bit of an unexpected result to me!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: ssg31415926</title>
		<link>http://alexlittle.net/blog/2007/09/11/javascript-addeventlistener-peculiarity-or-bug/comment-page-1/#comment-70</link>
		<dc:creator>ssg31415926</dc:creator>
		<pubDate>Fri, 21 Sep 2007 15:13:42 +0000</pubDate>
		<guid isPermaLink="false">http://alexlittle.net/blog/2007/09/11/javascript-addeventlistener-peculiarity-or-bug/#comment-70</guid>
		<description>I don&#039;t know anything about JavaScript but...

won&#039;t 10  be the value that i has at the end of the loop?

I think your script is setting up the elements with the function &#039;test(i)&#039; not e.g. &#039;test(1)&#039; or &#039;test(2)&#039; or whatever.</description>
		<content:encoded><![CDATA[<p>I don&#8217;t know anything about JavaScript but&#8230;</p>
<p>won&#8217;t 10  be the value that i has at the end of the loop?</p>
<p>I think your script is setting up the elements with the function &#8216;test(i)&#8217; not e.g. &#8216;test(1)&#8217; or &#8216;test(2)&#8217; or whatever.</p>
]]></content:encoded>
	</item>
</channel>
</rss>

