Creates an array with the results of calling a function on every element.
npm install array-map-x href="https://travis-ci.org/Xotic750/array-map-x"
title="Travis status"> src="https://travis-ci.org/Xotic750/array-map-x.svg?branch=master"
alt="Travis status" height="18">
href="https://david-dm.org/Xotic750/array-map-x"
title="Dependency status"> alt="Dependency status" height="18"/>
href="https://david-dm.org/Xotic750/array-map-x?type=dev"
title="devDependency status"> alt="devDependency status" height="18"/>
href="https://badge.fury.io/js/array-map-x"
title="npm version"> alt="npm version" height="18">
href="https://www.jsdelivr.com/package/npm/array-map-x"
title="jsDelivr hits"> alt="jsDelivr hits" height="18">
href="https://bettercodehub.com/results/Xotic750/array-map-x"
title="bettercodehub score"> alt="bettercodehub score" height="18">
href="https://coveralls.io/github/Xotic750/array-map-x?branch=master"
title="Coverage Status"> alt="Coverage Status" height="18">
Creates an array with the results of calling a function on every element.
This method creates a new array with the results of calling a provided
function on every element in the calling array.
Kind: Exported member
Returns: array - A new array with each element being the result of the
callback function.
Throws:
- TypeError If array is null or undefined.
- TypeError If callBack is not a function.
| Param | Type | Description |
| --------- | --------------------- | ----------------------------------------------- |
| array | array | The array to iterate over. |
| callBack | function | Function that produces an element of the Array. |
| [thisArg] | \* | Value to use as this when executing callback. |
Example
``js
import map from 'array-map-x';
const numbers = [1, 4, 9];
console.log(map(numbers, Math.sqrt));// [1, 2, 3]
console.log(numbers)); // [1, 4, 9]
``