【问题标题】:array index to series序列的数组索引
【发布时间】:2023-01-16 14:33:05
【问题描述】:

我有一组这样的对象

0: {slot_id: 'slot_8848241006_1657877963_1657886201'}
2: {slot_id: 'slot_8848241006_1657877963_1657886978'}
4: {slot_id: 'slot_9495414200_1657194770_1657877482'}
6: {slot_id: 'slot_9495414200_1657194770_1657886410'}
8: {slot_id: 'slot_9495414200_1657194770_1657886563'}

我想要这样

0: {slot_id: 'slot_8848241006_1657877963_1657886201'}
1: {slot_id: 'slot_8848241006_1657877963_1657886978'}
2: {slot_id: 'slot_9495414200_1657194770_1657877482'}
3: {slot_id: 'slot_9495414200_1657194770_1657886410'}
4: {slot_id: 'slot_9495414200_1657194770_1657886563'}

在如何更改数组的索引值方面需要帮助?

【问题讨论】:

    标签: arrays indexof


    【解决方案1】:
    //empty array
    var array = [0, 1, 2, 3, , 3,,,,,, 4,, 4,, 5,, 6,,,,];
    
    var filtered = array.filter(function (el) {
    return el != null;
    });
    console.log(filtered);
    

    【讨论】:

      猜你喜欢
      • 2020-06-19
      • 2019-03-22
      • 1970-01-01
      • 2023-03-30
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-12-01
      相关资源
      最近更新 更多