The question is pretty old, but nowadays you can use forEach, which is efficient and will retain the keys as numbers:
let keys = widthRange.map((v,k) => k).filter(i=>i!==undefined))
This loops through widthRange and makes a new array with the value of the keys, and then filters out all sparce slots by only taking the values that are defined.
(Bad idea, but for thorughness: If slot 0 was always empty, that could be shortened to filter(i=>i)
or filter(Boolean)
And, it may be less efficient, but the numbers can be cast with let keys = Object.keys(array).map(i=>i*1)