How to create an array in JavaScript whose indexing starts at 1?

It isn’t trivial. It’s impossible. The best you could do is create an object using numeric properties starting at 1 but that’s not the same thing.

Why exactly do you want it to start at 1? Either:

  • Start at 0 and adjust your indices as necessary; or

  • Start at 0 and just ignore index 0 (ie only use indices 1 and up).

Leave a Comment