It's not possible to use fill
alone to do what you ask. You'll have to combine it with one or more other methods.
I can't say I recommend this approach, because it really doesn't feel like idiomatic JavaScript, but just for demonstration purposes, here's a solution that uses fill
to populate the resulting array (instead of just using it to get around the awkwardness of the Array constructor). It's also more verbose and probably less performant than the alternatives.
console.log(Array.from({ length: 500 }).reduce((x, y, i, a) => (a.fill(i, i, i + 1), a), []))
For what it's worth, I find Array.from({ length: 500 }, (_, i) => i)
as @Terry suggested to be a much more elegant.