AMNLLY 2018-10-16 16:11
浏览 1303

js push()后 数组顺序发生改变,但数组console第0位和整体console的第0位不同

代码如下:
var dataValue = [];
for(var ii=0;ii<data.length;ii++){
// console.log(dataValue)
var ky = {province:'', oneLevel:'', twoLevel:'', busCount:'', scaling:'', increase:'' };
//s console.log(data[i][0])
ky.province=data[ii][0];
ky.oneLevel=data[ii][1];
ky.twoLevel=data[ii][2];
ky.busCount=data[ii][3];
ky.scaling=data[ii][4];
ky.increase=data[ii][5];

                 dataValue.push(ky);

           }
           console.log(dataValue);
           console.log(dataValue[0])
                    **  后台返回数据**

0: (6) ["第二个", "uoo", "小计", 1, 1, 1]
1: (6) ["第二个", "wqe", "小计", 1, 1, 1]
2: (6) ["第二个", "一", "231", 1, 3, 1]
3: (6) ["第二个", "一", "二", 2, 2, 1]
4: (6) ["第二个", "一", "小计", 2, 2, 1]
5: (6) ["第一个", "uoo", "23", 2, 2, 1]
6: (6) ["第一个", "uoo", "如图", 2, 2, 1]
7: (6) ["第一个", "uoo", "小计", 5, 2, 0.4]
8: (6) ["第一个", "wqe", "41", 2, 3, 1]
9: (6) ["第一个", "wqe", "无法", 2, 3, 1]
10: (6) ["第一个", "wqe", "小计", 2, 1, 0.5]
11: (6) ["第一个", "一", "231", 4, 1, 1]
12: (6) ["第一个", "一", "二", 1, 1, 1]
13: (6) ["第一个", "一", "小计", 1, 2, 2]
**整体console
0: {province: "第一个", oneLevel: "uoo", twoLevel: "小计", busCount: 5, scaling: 2, …}
1: {province: "第二个", oneLevel: "uoo", twoLevel: "小计", busCount: 1, scaling: 1, …}
2: {province: "第二个", oneLevel: "一", twoLevel: "231", busCount: 1, scaling: 3, …}
3: {province: "第二个", oneLevel: "一", twoLevel: "二", busCount: 2, scaling: 2, …}
4: {province: "第二个", oneLevel: "一", twoLevel: "小计", busCount: 2, scaling: 2, …}
5: {province: "第一个", oneLevel: "uoo", twoLevel: "23", busCount: 2, scaling: 2, …}
6: {province: "第一个", oneLevel: "uoo", twoLevel: "如图", busCount: 2, scaling: 2, …}
7: {province: "第二个", oneLevel: "wqe", twoLevel: "小计", busCount: 1, scaling: 1, …}
8: {province: "第一个", oneLevel: "wqe", twoLevel: "41", busCount: 2, scaling: 3, …}
9: {province: "第一个", oneLevel: "wqe", twoLevel: "无法", busCount: 2, scaling: 3, …}
10: {province: "第一个", oneLevel: "wqe", twoLevel: "小计", busCount: 2, scaling: 1, …}
11: {province: "第一个", oneLevel: "一", twoLevel: "231", busCount: 4, scaling: 1, …}
12: {province: "第一个", oneLevel: "一", twoLevel: "二", busCount: 1, scaling: 1, …}
13: {province: "第一个", oneLevel: "一", twoLevel: "小计", busCount: 1, scaling: 2, …}

只console第一个
{province: "第二个", oneLevel: "uoo", twoLevel: "小计", busCount: 1, scaling: 1, …}

两个不一样,为什么?
求大神帮忙解答

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥25 matlab数值溢出该怎么解决?
    • ¥15 大家帮我看看为什么错了
    • ¥15 unity互动琴弦抖动效果
    • ¥15 做了个的二极管反向饱和电流测量电路,但是测试达不到效果
    • ¥15 nginx无证书访问https失败
    • ¥15 树莓派启动AP热点传入数据
    • ¥15 multisim中关于74ls192n和DSWPK开关的问题(相关搜索:计数器)
    • ¥15 在误装Windows server2019 后如何利用Windows.old恢复?
    • ¥20 代码实现状态连接包过滤防火墙的设计与实现
    • ¥15 vscode的红色箭头爆红和has no default export报错