I use this code to clone an object. At the end I test the properties:
[code]
//cloning codes
function Clone(){}
function clone(obj) {
Clone.prototype = obj;
return new Clone();
}
//
var Orange={nature:’fruit’,color:’orange’}
var Banana=clone(Orange);
for(a in Banana){
alert(a)
}
So far so good. I see: nature – > color
But now I want to change a property of the Banana object, the color, then test again the properties:
[code]
Banana.color=’green’;
for(a in Banana){
alert(a)
}
Surprisingly, the changed property becomes the first in the loop, which is curious. I see now: color – > nature
Can anyone explain me why? I understand that the last [I]new[I]value
Is there a way to keep the order within the prototype members?
Additional note: The worse thing is that the order changes within the browsers. FF and IE act different. Is there any standard for that? Who does not follow it?