This time I will bring you JS random sortingarray, what are theprecautionsfor JS randomly sorting array, the following is a practical case, let's take a look.
The example in this article describes the method of JS generating randomly scrambled arrays. Share it with everyone for your reference, the details are as follows:
1. A messy sorting method
function fnLuanXu(num) { var aLuanXu=[]; for (var i = 0; ioperation result:
2. A less messy sorting method, jsbuilt-in function.
function fnLuanXu(num) { var aLuanXu=[]; for (var i = 0; i 0.5?-1:1;}) return aLuanXu; } //测试: console.log(fnLuanXu(7));Copy after login
I believe you have mastered the method after reading the case in this article. For more exciting information, please pay attention to other related articles on the php Chinese website!
Recommended reading:
Use fastclick source code to parse tap
The above is the detailed content of JS randomly sort array. For more information, please follow other related articles on the PHP Chinese website!