This article describes the method of javascript to randomly read arrays. Share it for your reference. The details are as follows:
function write_quote() { var quotes = [ 'no animals were harmed while making this page', 'made in ulm', 'this page was handmade', 'Get <a href="/products/firefox/">FireFox</a> :-)' ]; var r = (() * (-1)); // write the quote (quotes[r]); // or replace an HTML element: // ("quote").innerHTML = quotes[r]; }
I hope this article will be helpful to everyone's JavaScript programming.