<?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: Array.indexOf in Internet Explorer</title>
	<atom:link href="http://soledadpenades.com/2007/05/17/arrayindexof-in-internet-explorer/feed/" rel="self" type="application/rss+xml" />
	<link>http://soledadpenades.com/2007/05/17/arrayindexof-in-internet-explorer/</link>
	<description>repeat 4[fd 100 rt 90]</description>
	<lastBuildDate>Mon, 30 Aug 2010 18:41:27 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
	<item>
		<title>By: JavaScript, return index of an element in array &#8212; all your code are belong to us</title>
		<link>http://soledadpenades.com/2007/05/17/arrayindexof-in-internet-explorer/#comment-57481</link>
		<dc:creator>JavaScript, return index of an element in array &#8212; all your code are belong to us</dc:creator>
		<pubDate>Mon, 30 Aug 2010 18:41:27 +0000</pubDate>
		<guid isPermaLink="false">http://www.soledadpenades.com/2007/05/17/arrayindexof-in-internet-explorer/#comment-57481</guid>
		<description>[...] to this post I was able to quickly fix it by adding below code to my [...]</description>
		<content:encoded><![CDATA[<p>[...] to this post I was able to quickly fix it by adding below code to my [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Nan</title>
		<link>http://soledadpenades.com/2007/05/17/arrayindexof-in-internet-explorer/#comment-57326</link>
		<dc:creator>Nan</dc:creator>
		<pubDate>Tue, 24 Aug 2010 16:14:05 +0000</pubDate>
		<guid isPermaLink="false">http://www.soledadpenades.com/2007/05/17/arrayindexof-in-internet-explorer/#comment-57326</guid>
		<description>I FOUND THIS A VERY GOOD SOLUTION!

Marius

20080625 Array.indexOf(value) 

Simple jQuery solution:
jQuery.inArray(value, Array)</description>
		<content:encoded><![CDATA[<p>I FOUND THIS A VERY GOOD SOLUTION!</p>
<p>Marius</p>
<p>20080625 Array.indexOf(value) </p>
<p>Simple jQuery solution:<br />
jQuery.inArray(value, Array)</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: sole</title>
		<link>http://soledadpenades.com/2007/05/17/arrayindexof-in-internet-explorer/#comment-57245</link>
		<dc:creator>sole</dc:creator>
		<pubDate>Fri, 20 Aug 2010 10:48:00 +0000</pubDate>
		<guid isPermaLink="false">http://www.soledadpenades.com/2007/05/17/arrayindexof-in-internet-explorer/#comment-57245</guid>
		<description>Thanks Christian. A very thorough explanation, much appreciated!</description>
		<content:encoded><![CDATA[<p>Thanks Christian. A very thorough explanation, much appreciated!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Christian C. Salvadó</title>
		<link>http://soledadpenades.com/2007/05/17/arrayindexof-in-internet-explorer/#comment-57199</link>
		<dc:creator>Christian C. Salvadó</dc:creator>
		<pubDate>Wed, 18 Aug 2010 05:02:15 +0000</pubDate>
		<guid isPermaLink="false">http://www.soledadpenades.com/2007/05/17/arrayindexof-in-internet-explorer/#comment-57199</guid>
		<description>Hello, I just have a couple of comments:

The `Array.prototype.indexOf` method is now part of the ECMAScript 5th Edition Standard (published on Dec 2009), and finally, it has been correctly implemented on IE9 (which still in its Preview stage).

About your implementation, there are some flaws that I would like to address.

Checking:

    if(!Array.indexOf){
      //..
    }

And later assigning the `Array.prototype.indexOf` property is not right, they two are different methods!

`Array.indexOf` is part of the &quot;Array Generics&quot; methods, introduced on the Mozilla Implementations only! (Rhino and SpiderMonkey, in JavaScript(TM) 1.7), and it is not part of the ECMAScript standard.

`Array.indexOf` does *not* exist on other ECMA-compliant implementations, for example in Safari, Chrome, WebKit and even in IE9, while they do implement the standard native `Array.prototype.indexOf` method.

This means that in those implementations the native method will be replaced with your code!, and that&#039;s pretty bad, native methods are extremely fast and should be respected (check for `Array.prototype.indexOf`!).


In the ECMAScript 5th Edition Standard the method is completely described ( http://j.mp/cqP6r7 ), it needs to handle a second argument, a &quot;fromIndex&quot; to start the search looking forward from it (which can also be negative, in that case it will be taken as the offset from the end of the array).

Also, the method should compare the elements of the array using the Strict Equality operator, `===`. Comparing with the equals operator `==` will give you different results, for example:

    [&#039;0&#039;].indexOf(0); // Should return `-1`

But your implementation will return `0`, because the `===` operator does not make any type conversion (`&#039;0&#039; == 0` produces true but `&#039;0&#039; === 0` evaluates to false).

Aside of that, the method is described in the specification as &quot;generic&quot;, that means that it can be used on &quot;array-like&quot; objects, (an object that has a `length` property, and its value should be within the range of a 32-bit unsigned integer (from 0 to 2^32-1) and that contains numeric properties), e.g.:

    var arrayLike = {0:&#039;foo&#039;, length:1};
    Array.prototype.indexOf.call(arrayLike, &#039;foo&#039;); // 0

Your method is capable to handle the above example, but imagine what would happen if `length` were an arbitrary value like `Infinity` for example...

The algorithm described in the specification also checks the value of the `length` property ensuring that it is a Uint32...

There are even more aspects that a standards compliant implementation should check, but this comment is getting quite long :-)

A complete standards compliant method can be found on the Mozilla Developer Center: http://j.mp/aQtCpG 


Thanks!</description>
		<content:encoded><![CDATA[<p>Hello, I just have a couple of comments:</p>
<p>The `Array.prototype.indexOf` method is now part of the ECMAScript 5th Edition Standard (published on Dec 2009), and finally, it has been correctly implemented on IE9 (which still in its Preview stage).</p>
<p>About your implementation, there are some flaws that I would like to address.</p>
<p>Checking:</p>
<p>    if(!Array.indexOf){<br />
      //..<br />
    }</p>
<p>And later assigning the `Array.prototype.indexOf` property is not right, they two are different methods!</p>
<p>`Array.indexOf` is part of the &#8220;Array Generics&#8221; methods, introduced on the Mozilla Implementations only! (Rhino and SpiderMonkey, in JavaScript(TM) 1.7), and it is not part of the ECMAScript standard.</p>
<p>`Array.indexOf` does *not* exist on other ECMA-compliant implementations, for example in Safari, Chrome, WebKit and even in IE9, while they do implement the standard native `Array.prototype.indexOf` method.</p>
<p>This means that in those implementations the native method will be replaced with your code!, and that&#8217;s pretty bad, native methods are extremely fast and should be respected (check for `Array.prototype.indexOf`!).</p>
<p>In the ECMAScript 5th Edition Standard the method is completely described ( <a href="http://j.mp/cqP6r7" rel="nofollow">http://j.mp/cqP6r7</a> ), it needs to handle a second argument, a &#8220;fromIndex&#8221; to start the search looking forward from it (which can also be negative, in that case it will be taken as the offset from the end of the array).</p>
<p>Also, the method should compare the elements of the array using the Strict Equality operator, `===`. Comparing with the equals operator `==` will give you different results, for example:</p>
<p>    ['0'].indexOf(0); // Should return `-1`</p>
<p>But your implementation will return `0`, because the `===` operator does not make any type conversion (`&#8217;0&#8242; == 0` produces true but `&#8217;0&#8242; === 0` evaluates to false).</p>
<p>Aside of that, the method is described in the specification as &#8220;generic&#8221;, that means that it can be used on &#8220;array-like&#8221; objects, (an object that has a `length` property, and its value should be within the range of a 32-bit unsigned integer (from 0 to 2^32-1) and that contains numeric properties), e.g.:</p>
<p>    var arrayLike = {0:&#8217;foo&#8217;, length:1};<br />
    Array.prototype.indexOf.call(arrayLike, &#8216;foo&#8217;); // 0</p>
<p>Your method is capable to handle the above example, but imagine what would happen if `length` were an arbitrary value like `Infinity` for example&#8230;</p>
<p>The algorithm described in the specification also checks the value of the `length` property ensuring that it is a Uint32&#8230;</p>
<p>There are even more aspects that a standards compliant implementation should check, but this comment is getting quite long :-)</p>
<p>A complete standards compliant method can be found on the Mozilla Developer Center: <a href="http://j.mp/aQtCpG" rel="nofollow">http://j.mp/aQtCpG</a> </p>
<p>Thanks!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Mahi</title>
		<link>http://soledadpenades.com/2007/05/17/arrayindexof-in-internet-explorer/#comment-56713</link>
		<dc:creator>Mahi</dc:creator>
		<pubDate>Thu, 29 Jul 2010 03:51:11 +0000</pubDate>
		<guid isPermaLink="false">http://www.soledadpenades.com/2007/05/17/arrayindexof-in-internet-explorer/#comment-56713</guid>
		<description>Thanx men this helped me alot :)</description>
		<content:encoded><![CDATA[<p>Thanx men this helped me alot :)</p>
]]></content:encoded>
	</item>
</channel>
</rss>
