aboutsummaryrefslogtreecommitdiff
path: root/examples/change-array-by-copy.js
blob: 78cf6f3de39506358a99e859db5468da837b81c0 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
const sequence = [1, 2, 3];
sequence.toReversed(); // => [3, 2, 1]
sequence; // => [1, 2, 3]

const outOfOrder = new Uint8Array([3, 1, 2]);
outOfOrder.toSorted(); // => Uint8Array [1, 2, 3]
outOfOrder; // => Uint8Array [3, 1, 2]

const correctionNeeded = [1, 1, 3];
correctionNeeded.with(1, 2); // => [1, 2, 3]
correctionNeeded; // => [1, 1, 3]