aboutsummaryrefslogtreecommitdiff
path: root/examples/change-array-by-copy.js
diff options
context:
space:
mode:
Diffstat (limited to 'examples/change-array-by-copy.js')
-rw-r--r--examples/change-array-by-copy.js11
1 files changed, 11 insertions, 0 deletions
diff --git a/examples/change-array-by-copy.js b/examples/change-array-by-copy.js
new file mode 100644
index 000000000..78cf6f3de
--- /dev/null
+++ b/examples/change-array-by-copy.js
@@ -0,0 +1,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]