BetterJS provide a shuffle method on Array.prototype, with O(n) time and space complexity.
import 'https://better-js.fenz.land/src/array-prototype/shuffle-and-shuffled.js';
const array= [ 0, 1, 2, 3, ];
array.shuffle() // return array itself with shuffled
console.log( array, ) // maybe [ 2, 1, 3, 0, ]