-2

How do I get the number of "columns" in this multi dim array?

The number of "rows", I can get with x.length (returns 3)

x[0].length is undefined but should return 4. It's probably easy but I don't figure it out.

(3) [{…}, {…}, {…}]
0: {0: "1", 1: "2", 2: "3", 3: "4
"}
1: {0: "5", 1: "6", 2: "7", 3: "8
"}
2: {0: "9", 1: "10", 2: "11", 3: "12
"}
length: 3
__proto__: Array(0)
smolo
  • 280
  • 4
  • 18

1 Answers1

2

You should get the length of the keys of the first object

console.log(Object.keys(x[0]).length)
Maheer Ali
  • 32,967
  • 5
  • 31
  • 51