antd-mobile
Version:
<img src="https://gw.alipayobjects.com/mdn/rms_ee68a8/afts/img/A*hjjDS5Yy-ooAAAAAAAAAAAAAARQnAQ" alt="logo" width="100%" />
22 lines (18 loc) • 427 B
JavaScript
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.shuffle = shuffle;
/**
* 数组打乱
* @param array 任意数组
* @returns any[] 打乱后的数组
*/
function shuffle(array) {
const result = [...array];
for (let i = result.length; i > 0; i--) {
const j = Math.floor(Math.random() * i);
[result[i - 1], result[j]] = [result[j], result[i - 1]];
}
return result;
}
;