Skip to content

Latest commit

 

History

History

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 
 
 
 
 
 
 

README.md

zip2object

Create an object from a provided list of properties and a provided list of corresponding values.

Usage

var zip2object = require( '@stdlib/array/base/zip2object' );

zip2object( properties, values )

Returns an object from a provided list of properties and a provided list of corresponding values.

var properties = [ 'a', 'b' ];
var values = [ 1, 2 ];

var out = zip2object( properties, values );
// returns { 'a': 1, 'b': 2 }

The function supports the following parameters:

  • properties: list of properties.
  • values: list of values.
  • The function assumes that both input arrays have the same length.

Examples

var discreteUniform = require( '@stdlib/random/array/discrete-uniform' );
var zeroTo = require( '@stdlib/array/base/zero-to' );
var zip2object = require( '@stdlib/array/base/zip2object' );

var x1 = zeroTo( 10 );
var x2 = discreteUniform( x1.length, -100, 100 );

var out = zip2object( x1, x2 );
// returns {...}