Fisher-Yates 洗牌算法(不修改原数组) Fisher-Yates shuffle algorithm (non-mutating)
需要洗牌的数组 / Array to shuffle
洗牌后的新数组 / New shuffled array
// 不修改原数组const original = [1, 2, 3, 4, 5]const shuffled = shuffleImmutable(original) // original 保持不变 Copy
// 不修改原数组const original = [1, 2, 3, 4, 5]const shuffled = shuffleImmutable(original) // original 保持不变
Fisher-Yates 洗牌算法(不修改原数组) Fisher-Yates shuffle algorithm (non-mutating)