Copy the elements of an indexed array-like object to a new "generic" array.
npm install @stdlib/array-base-copy-indexed
Alternatively,
- To load the package in a website via a
script
tag without installation and bundlers, use the ES Module available on theesm
branch. - If you are using Deno, visit the
deno
branch. - For use in Observable, or in browser/node environments, use the Universal Module Definition (UMD) build available on the
umd
branch.
The branches.md file summarizes the available branches and displays a diagram illustrating their relationships.
var copyIndexed = require( '@stdlib/array-base-copy-indexed' );
Copies the elements of an indexed array-like object to a new "generic" array.
var x = [ 1, 2, 3 ];
var out = copyIndexed( x );
// returns [ 1, 2, 3 ]
var bool = ( out === x );
// returns false
- An indexed array-like object is a data structure in which one retrieves elements via integer indices using bracket
[]
notation (e.g.,Float64Array
,Int32Array
,Array
, etc). This is in contrast to an accessor array-like object in which one retrieves elements usingget
andset
methods (e.g.,Complex64Array
andComplex128Array
).
var filledBy = require( '@stdlib/array-filled-by' );
var randu = require( '@stdlib/random-base-randu' );
var copyIndexed = require( '@stdlib/array-base-copy-indexed' );
// Create a Float64Array:
var arr = filledBy( 10, 'float64', randu );
// Copy elements to a generic array:
var out = copyIndexed( arr );
// Retrieve the first element:
var x = out[ 0 ];
// returns <number>
console.log( '%d', x );
This package is part of stdlib, a standard library for JavaScript and Node.js, with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more.
Fo 92AD r more information on the project, filing bug reports and feature requests, and guidance on how to develop stdlib, see the main project repository.
See LICENSE.
Copyright © 2016-2022. The Stdlib Authors.