如何将对象拆分为数组

时间:2019-12-23 19:45:38

标签: javascript arrays object

有人请我解决我的问题。

我尝试在此处学习基本数据。如何将每10个对象分成 n 个数组。 我有一些这样的对象:

let data = { 
  _11_id_type_room_property: 11,
  _11_name_type_room_property: 'Double Bed',
  _11_total_room_property: 0,
  _11_size_room_property1: 0,
  _11_size_room_property2: 0,
  _11_additional_bed_property: 0,
  _11_daily_price_property: 0,
  _11_weekend_price_property: 0,
  _11_monthly_price_property: 0,
  _11_annual_price_property: 0,
  _44_id_type_room_property: 44,
  _44_name_type_room_property: 'Deluxe Queen',
  _44_total_room_property: 0,
  _44_size_room_property1: 0,
  _44_size_room_property2: 0,
  _44_additional_bed_property: 0,
  _44_daily_price_property: 0,
  _44_weekend_price_property: 0,
  _44_monthly_price_property: 0,
  _44_annual_price_property: 0 
}

我如何每隔10个对象键,其外观如下:

let data = [{ 
  _11_id_type_room_property: 11,
  _11_name_type_room_property: 'Double Bed',
  _11_total_room_property: 0,
  _11_size_room_property1: 0,
  _11_size_room_property2: 0,
  _11_additional_bed_property: 0,
  _11_daily_price_property: 0,
  _11_weekend_price_property: 0,
  _11_monthly_price_property: 0,
  _11_annual_price_property: 0,
},
{
  _44_id_type_room_property: 44,
  _44_name_type_room_property: 'Deluxe Queen',
  _44_total_room_property: 0,
  _44_size_room_property1: 0,
  _44_size_room_property2: 0,
  _44_additional_bed_property: 0,
  _44_daily_price_property: 0,
  _44_weekend_price_property: 0,
  _44_monthly_price_property: 0,
  _44_annual_price_property: 0 
}]

谢谢

0 个答案:

没有答案