๐ŸŽฎ sort() vs toSorted(): watch the reference

Classic methods (sort, reverse, splice) mutate the array and hand back the same reference โ€” so React compares by identity, sees no change, and skips the re-render. ES2023's toSorted, toReversed, toSpliced, with return a new array. Click one and watch result === original flip.

1 ยท Run a method on the array

โš ๏ธ Mutating โ€” returns the same array
โœ“ Immutable โ€” returns a new array

2 ยท What just happened

Click a method above. You'll see the array it returned, whether the original was mutated, whether result === original, and โ€” the whole point โ€” whether React would re-render.