How to iterate array keys in JavaScript?

To iterate array keys in JavaScript, we use the Object.keys method to get an array of string keys from the array.

For instance, we write

const array = [];
widthRange[46] = { sel: 46, min: 0, max: 52 };
widthRange[66] = { sel: 66, min: 52, max: 70 };
widthRange[90] = { sel: 90, min: 70, max: 94 };
const keys = Object.keys(array);

to call Object.keys with array to return an array of indexes of the array array.