0

Is the order guaranteed when iterating an array with keys?

My code:

const data = {};
data["a"] = 1;
data["c"] = 2;
data["b"] = 3;

for (const id in data) {
    console.log(data[id]);
}

Result:

1
2
3

Is the result guaranteed to always be the same?

Zack Lee
  • 2,784
  • 6
  • 35
  • 77

0 Answers0