@writetome51/get-array-copy
TypeScript icon, indicating that this package has built-in type declarations

2.0.0 • Public • Published

getArrayCopy<T>(array: T[]): T[]

Returns an identical but independent copy of array, not referencing the original.

Example

let arr = [1,2,3,4,5];  
let copy = getArrayCopy(arr);  
copy.push(10); // copy === [1,2,3,4,5,10]

// But the original hasn't changed:
console.log(arr);
// [1,2,3,4,5]

Installation

npm i @writetome51/get-array-copy

Loading

import {getArrayCopy} from '@writetome51/get-array-copy';

Dependencies (1)

Dev Dependencies (0)

    Package Sidebar

    Install

    npm i @writetome51/get-array-copy

    Weekly Downloads

    2

    Version

    2.0.0

    License

    MIT

    Unpacked Size

    2.29 kB

    Total Files

    5

    Last publish

    Collaborators

    • writetome51