Javascript 如何获取对象属性值的数组。?

Javascript 如何获取对象属性值的数组。?,javascript,arrays,Javascript,Arrays,我有这个对象数组,我只需要那些在给定的时隙上属性值大于0的对象,我如何得到这样的输出 var array = [ { time: "10:30", slot: 3, product_Id: 77, amount: 30 } , { time: "11:00", slot: 4, product_Id: 77, amount: 30 } , { time: "11:30", slot: 2, product_Id: 77, amount: 30 } , { time: "12:00

我有这个对象数组,我只需要那些在给定的时隙上属性值大于0的对象,我如何得到这样的输出

var array = [
  { time: "10:30", slot: 3, product_Id: 77, amount: 30 }
  , { time: "11:00", slot: 4, product_Id: 77, amount: 30 }
  , { time: "11:30", slot: 2, product_Id: 77, amount: 30 }
  , { time: "12:00", slot: 0, product_Id: 77, amount: 30 }
  , { time: "12:30", slot: 0, product_Id: 77, amount: 30 }
]
输出:

booking_items: [{
        "product_id": "",
        "slot_time": " "
        "slot_quantity": "",
        "amount": "",
        "sub_amount": ""
    },
    {
        "product_id": "",
        "slot_time": ""
        "slot_quantity": "",
        "amount": "",
        "sub_amount": ""
    }
]
我们可以使用
filter()

var数组=[
{时间:“10:30”,时段:3,产品编号:77,金额:30},
{时间:“11:00”,时段:4,产品编号:77,金额:30},
{时间:“11:30”,时段:2,产品编号:77,金额:30},
{时间:“12:00”,时隙:0,产品编号:77,金额:30},
{时间:“12:30”,时隙:0,产品编号:77,金额:30}
]
var booking\u items=array.filter(obj=>obj.slot>0)

console.log(预订项目)
给出一些示例时间和相应的输出。所以我们可以尝试基于thathi@sarvonks,我们可以基于n条件返回另一个对象吗==0然后返回另一个对象。为什么输出中的所有属性都是空字符串?请用您迄今为止尝试过的方法创建一个?您好,谢谢,我如何获得每次的插槽值。?我不确定我是否理解您的意思,您能否澄清您希望发生的事情和所需的输出?我需要通过比较插槽的第一个属性即时间来获得插槽属性值。将进行什么比较?对不起,我仍然不确定您想要实现什么。请检查这些时段的预定时间。就像有人在10:30预订了3个插槽一样,我们将其存储在插槽数量中。我把沙箱装在这里。谢谢你的帮助。