2.0.0 • Published 3 years ago

@writetome51/get-array-copy v2.0.0

Weekly downloads
-
License
MIT
Repository
-
Last release
3 years ago

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';