Learn about our RFC process, Open RFC meetings & more.Join in the discussion! »

@writetome51/get-array-copy

1.0.0 • Public • Published

getArrayCopy(array): any[]

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

Install

npm i @writetome51/get-array-copy

DownloadsWeekly Downloads

1

Version

1.0.0

License

MIT

Unpacked Size

2.2 kB

Total Files

4

Last publish

Collaborators

  • avatar