Math.floor(Math.random() * length)will give you a random index in the array, provided that length comes from array.length. The precision of this implementation over 10 million iterations is near perfect, with the biggest difference being 0.08-0.20%.
Some languages, like Elixir or Python, come with functionality to pick a random element from enumerable data-types (such as Arrays). In other languages, like Go or Java, you have to write the logic yourself, (sometimes) using fairly convoluted logic (Seeding random generators, etc.).