Capítulo 143 de 411

Chapter 143: gsap.utils.shuffle()

Core Idea

shuffle() randomly reorders an array in place, returning the same array (not a copy).

Code Examples

let array = [1, 2, 3, 4, 5];
gsap.utils.shuffle(array); // same array, reordered, e.g. [2, 5, 3, 1, 4]

Key Takeaways

  1. Mutates the original array — copy it first if you need to preserve the original order.