Chrome – Array.prototype.slice(…) Difference

At first I thought this was an infinite loop bug issue. After that, I thought it was just simply a bug. Now, after a co-worker (Geoff) pointed me to the JavaScript specs, I see that Chrome implemented this correctly and others didn’t. In most browsers the following code would result in an empty array, but in Chrome (at least in v34.0.1847.116) you will get an array of length 4294967295:


Immediately you would think this is a bug but interestingly if you do the following you will get an array of length 1:


After looking at the specs you can see that the length is converted to a 32-bit integer:

Leave a Reply

Your email address will not be published. Required fields are marked *

− five = 4

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre class="">