0

From what I can tell when I dynamically make a new column without using a push it is done backwards in IE. Doing a sheet[r].push() would not work so I dont know how else to do this.

Going to illustrate this in a code flow.

 //{" ":"545"} current object.
 sheet[r][colN[elmt][ceeLineData.ColLabel].toString()] = dat[count + c].data;
 //{" ":"545","20":"1"} current object.

So the line did nothing more then simply add a new column titled "20" with rowdata of "1" Something like this:

[" "]--["20"]//columns 0,1
["545"]["1"]//row 0

this is true for ff,safari,opera,chrome now for IE it did this

["20"]--[" "]
["1"]["545"]

why?

Here are the brake down values of the above for reference.

alert( r ) //0
alert( JSON.stringify( sheet[r] ) ); // {" ":"545"}
alert( c ) //1
alert( count + c ) //56
alert( dat[count + c].data ) //1
alert( elmt ) // 9 
alert( ceeLineData.ColLabel ) //BP In Hg
alert( colN[elmt][ceeLineData.ColLabel].toString() )//20
alert( JSON.stringify( sheet[r] ) ); // {" ":"545","20":"1"}//not IE
alert( JSON.stringify( sheet[r] ) ); // {"20":"1"," ":"545"}//IE
4

1 回答 1

1

当您使用像“”(空格)这样的属性名称时,您不会将元素附加到数组中。您只是向对象添加了一个命名属性。命名属性和数字索引的数组属性没有定义的顺序。实际上,看起来您甚至都没有数组;这些只是简单的对象,从它们用花括号记录的事实可以清楚地看出。

JavaScript Array 实例当然也是对象,但它们有特殊的行为。普通对象的属性没有定义的顺序,因此您不能期望系统(在记录对象时,或在for ... in循环中等)以任何特定顺序呈现它们。

于 2013-05-20T13:21:57.890 回答