Membuat perulangan di Javascript Object

Menggunakan for..in
Published di Javascript, a year ago

const jsonObject = {
  "480": {
    "card_id": 48,
    "block": "C",
    "rak": "01",
    "tier": "01",
    "row": "01",
    "qtyHistory": "2.00",
    "id": 480,
    "nama": "AIR CLEANER (RS)",
    "part_number": "A222100000265",
    "photo_thumbnail": null,
    "ift_number": "IFT230480",
    "merk_part_number": null,
    "availableStock": "2.00"
  },
  "603": {
    "card_id": 48,
    "block": "C",
    "rak": "01",
    "tier": "01",
    "row": "01",
    "qtyHistory": "4.00",
    "id": 603,
    "nama": "AIR FILTER SAFETY FILTER ELEMENT",
    "part_number": "B222100000640",
    "photo_thumbnail": null,
    "ift_number": "IFT230603",
    "merk_part_number": "",
    "availableStock": "14.00"
  }
};

for (const key in jsonObject) {
  const item = jsonObject[key];
  console.log(item.id, item.nama, item.part_number);
}

Dukung Saya supaya tetap menulis artikel-artikel yang baik, membayar sewa domain, dan server untuk blog ini. Caranya dengan donasi cendol via Trakteer.id.


No image

Fadly Dzil Jalal

PHP, Yii2 Framework, Laravel, Java, Java Swing, Hibernate, Javascript, Angular, React, MySQL, MongoDB


Dapatkan USD 200 untuk develop aplikasimu di DigitalOcean DigitalOcean Referral Badge