Files
scriptc/tests/corpus/2671-array-copying-js.cjs
T

10 lines
359 B
JavaScript

// JavaScript permits the zero-argument Array.prototype.toSpliced form even
// though TypeScript's declaration requires `start`. It returns a fresh
// shallow copy; it must not share the one-argument form's delete-to-end
// default.
const source = [1, 2, 3];
const copied = source.toSpliced();
copied[0] = 9;
console.log(copied.join(","), source.join(","));