Get a Random Array Item with JavaScript

1 · David Walsh · May 9, 2022, 11:06 a.m.
JavaScript Arrays are probably my favorite primitive in JavaScript. You can do all sorts of awesome things with arrays: get unique values, clone them, empty them, etc. What about getting a random value from an array? To get a random item from an array, you can employ Math.random: const arr = [ "one", "two", "three", […] The post Get a Random Array Item with JavaScript appeared first on David Walsh Blog. ...