Bug 104506 - The order of objects in an array are not sequential - Moz, FF, IE, Opera are okay
Summary: The order of objects in an array are not sequential - Moz, FF, IE, Opera are ...
Status: RESOLVED DUPLICATE of bug 28474
Alias: None
Product: konqueror
Classification: Applications
Component: kjs (show other bugs)
Version: unspecified
Platform: unspecified Linux
: NOR normal
Target Milestone: ---
Assignee: Konqueror Developers
Depends on:
Reported: 2005-04-25 04:58 UTC by Charles Phoenix
Modified: 2005-04-26 04:39 UTC (History)
0 users

See Also:
Latest Commit:
Version Fixed In:


Note You need to log in before you can comment on or make changes to this bug.
Description Charles Phoenix 2005-04-25 04:58:42 UTC
Version:           3.4.0 (using KDE 3.4.0, Gentoo)
Compiler:          gcc version 3.3.5-20050130 (Gentoo Linux, ssp-, pie-
OS:                Linux (i686) release 2.6.11-gentoo-r6

This is part of a large program... experimentation with rollovers and slideshows.

The functions in question...

JS_FADE.addImage = function(imgName, img, caption) {
	JS_FADE.gallery[imgName] = new Image();
	JS_FADE.gallery[imgName].src = img;
	JS_FADE.gallery[imgName].caption = caption;
	JS_FADE.gallery[imgName].imgName = imgName;
	JS_FADE.cycleListUpdate = false;

JS_FADE.updateCycleList = function() {
	var i;
	var j = 0;
	for (i in JS_FADE.gallery) {
		JS_FADE.cycleList[j] = JS_FADE.gallery[i].imgName;
	JS_FADE.cycleListUpdate = true;

and then JS_FADE.gallery is referenced
	newImgName = JS_FADE.cycleList[JS_FADE.cycleIndex];

I presume I am making a few mistakes in style, but it works in the other browser and sequential order is maintained.

The first function is called externally like so...

	JS_FADE.addImage ('apple', "images/apple.jpg", "This is an apple.");
	JS_FADE.addImage ('banana', "images/banana.jpg", "This is a banana.");
	JS_FADE.addImage ('cherries', "images/cherries.jpg", "These are cherries.");
	JS_FADE.addImage ('orange', "images/orange.jpg", "This is an orange.");
	JS_FADE.addImage ('pear', "images/pear.jpg", "This is a pear.");
	JS_FADE.addImage ('pineapple', "images/pineapple.jpg", "This is a pineapple.");
	JS_FADE.addImage ('prune', "images/prune.jpg", "This is a prune.");
	JS_FADE.addImage ('strawberry', "images/strawberry.jpg", "This is a strawberry.");

thus establishing the sequential order, presumably the behavior is the equivalent of a push on stack command?

but... to the order ends up being
pear, apple, pineapple, prune, orange, cherries, strawberry, banana

I compile from source so some gremlin could have awaken, unknown.

If someone wants to chase this I can send them a copy of my work ~300Kbytes.

Sidenote, is opacity working?
If not I will file another report.
Comment 1 Thiago Macieira 2005-04-25 06:11:15 UTC
So, if you do:

arr['cherry'] = 1;
arr['apple'] = 1;
arr['banana'] = 1;
for (i in arr)
  document.write(i + ' ');

The output will not necessarily be "cherry apple banana"?

If that is the case, unless the ECMA standard makes this contract, I don't see why the order should be kept. Alphabetic might be expected, but, again, unless mandated by the standard, there is no reason to. The internal representation is probably a hashing-table, whose iteration order is not guaranteed.

In fact, we can relate to:

arr[2] = 1;
arr[0] = 1;
arr[1] = 1;
for (i in arr)
The output will probably not be "201".
Comment 2 Maksim Orlovich 2005-04-25 06:15:00 UTC
See bug #28474, I think this is a dupe
Comment 3 Charles Phoenix 2005-04-25 13:03:48 UTC
Granted it is not "official" behavior but it is "unofficial" behavior. It comes down to a design choice.

Something to add to the learning... do not program based on *any* assumptions.

Thank you.

And yes you can mark this as dupe.
Comment 4 Thiago Macieira 2005-04-26 04:39:17 UTC
Reopening to mark as duplicate.
Comment 5 Thiago Macieira 2005-04-26 04:39:34 UTC

*** This bug has been marked as a duplicate of 28474 ***