get random item from array javascript

JavaScript
var colors = ["red","blue","green","yellow"];
var randomColor = colors[Math.floor(Math.random()*colors.length)]; //pluck a random color
//get random value from array
var colors = ["red","blue","green","yellow"];
var randColor = colors[Math.floor(Math.random() * colors.length)];
const randomElement = array[Math.floor(Math.random() * array.length)];
Source

Also in JavaScript: