js数组中随机取值
从数组中随机取值
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> </head> <body> </body> <script> window.onload = function() { var arr = ["009", "002", "006", "003", "001", "005"]; var index = Math.floor((Math.random()*arr.length)); console.log(arr[index]); } </script> </html>