Skip to content

Latest commit

 

History

History
15 lines (9 loc) · 366 Bytes

File metadata and controls

15 lines (9 loc) · 366 Bytes

Array.prototype.shuffle

BetterJS provide a shuffle method on Array.prototype, with O(n) time and space complexity.

Usage

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, ]