O
O
Orbite2019-09-20 17:44:50
JavaScript
Orbite, 2019-09-20 17:44:50

How to loop through a JS array?

Please tell me how to iterate over an array of the form using js or jquery:

Array
(
    [0] => Array
        (
            [id] => 45
            [description] => 11231
            [status] => 1
        )

    [1] => Array
        (
            [id] => 44
            [description] => блабла
            [status] => 1
        )
)

Answer the question

In order to leave comments, you need to log in

1 answer(s)
P
profesor08, 2019-09-20
@profesor08

const array = [
  {
    id: 44,
  },
  {
    id: 45,
  },
];

for (const item of array) {
  console.log(item.id);
}

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question