We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
var values = [1, 2, 3, 4, 5]; values.sort(function(){ return Math.random() - 0.5; }); console.log(values);
遍历数组元素,然后将当前元素与以后随机位置的元素进行交换
function shuffle(a) { for (let i = a.length; i; i--) { let j = Math.floor(Math.random() * i); [a[i - 1], a[j]] = [a[j], a[i - 1]]; } return a; }
mqyqingfeng/Blog#51
The text was updated successfully, but these errors were encountered:
No branches or pull requests
1)
2)
遍历数组元素,然后将当前元素与以后随机位置的元素进行交换
References
mqyqingfeng/Blog#51
The text was updated successfully, but these errors were encountered: