Xotic750 / array-map-x

Creates an array with the results of calling a function on every element.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Travis status Dependency status devDependency status npm version jsDelivr hits bettercodehub score Coverage Status

array-map-x

Creates an array with the results of calling a function on every element.

module.exportsarray

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

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]

About

Creates an array with the results of calling a function on every element.

License:MIT License


Languages

Language:JavaScript 100.0%