choirulz / base2

Automatically exported from code.google.com/p/base2
0 stars 0 forks source link

Array.forEach works different in Gecko vs WebKit/IE/Opera #2

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
Base.forEach will iterate twice over an Array created with "new Array(2)" in 
Safari, but zero times in 
Firefox. According to Firefox documentation:
"Description
forEach executes the provided function (callback) once for each element present 
in the array. 
callback is invoked only for indexes of the array which have assigned values; 
it is not invoked for 
indexes which have been deleted or which have never been assigned values."

http://developer.mozilla.org/en/docs/Core_JavaScript_1.5_Reference:Global_Object
s:Array:forEach

See also the attached test-case

Original issue reported on code.google.com by doeke.zanstra@gmail.com on 9 Apr 2007 at 4:10

Attachments:

GoogleCodeExporter commented 9 years ago
Tested Safari version is 2.0.4 (419.3)

Original comment by doeke.zanstra@gmail.com on 11 Apr 2007 at 12:21

GoogleCodeExporter commented 9 years ago
Base.forEach is intended for enumerating base2 objects *not* arrays. However, 
you are
still correct that the behavior is different in Gecko and that it is due to the
enumeration of undeclared slots in the array. So I will try to fix it. :-)

Original comment by dean.edw...@gmail.com on 12 Apr 2007 at 1:04

GoogleCodeExporter commented 9 years ago
Status changed to "Accepted".

Original comment by dean.edw...@gmail.com on 3 Jul 2007 at 4:17

GoogleCodeExporter commented 9 years ago
Fixed! Array.forEach now handles sparse arrays.

Original comment by dean.edw...@gmail.com on 10 Jul 2007 at 6:38

GoogleCodeExporter commented 9 years ago

Original comment by doek...@gmail.com on 14 Jul 2007 at 6:49