1.對陣列打亂順序
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>
<body>
<script>
var arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10];
arr.sort(function (a, b) {
return Math.random() - 0.5; //使用亂數,大于0.5的往后排,小于0.5的往前排
})
console.log(arr);
</script>
</body>
</html>
index.html
轉載請註明出處,本文鏈接:https://www.uj5u.com/qiye/115185.html
標籤:JavaScript
下一篇:什么是執行背景關系
