随笔分类 -  数组

摘要:let originalArray = [1,2,3,4,5,3,2,4,1]; // 方式1 const result = Array.from(new Set(originalArray)); console.log(result); // -> [1, 2, 3, 4, 5] // 方式2 c 阅读全文
posted @ 2020-03-30 10:12 epoch丶 阅读(117) 评论(0) 推荐(0)
摘要:1、随机数(不能完全乱序,性能较低) function shuffle(array) { array.sort(() => Math.random() - 0.5); } let arr = [1, 2, 3]; shuffle(arr); alert(arr); 2、Fisher–Yates sh 阅读全文
posted @ 2020-01-14 10:56 epoch丶 阅读(167) 评论(0) 推荐(0)