UNPKG

mathjs

Version:

Math.js is an extensive math library for JavaScript and Node.js. It features a flexible expression parser with support for symbolic computation, comes with a large set of built-in functions and constants, and offers an integrated solution to work with dif

43 lines (27 loc) 878 B
<!-- Note: This file is automatically generated from source code comments. Changes made in this file will be overridden. --> # Function map Create a new matrix or array with the results of the callback function executed on each entry of the matrix/array. ## Syntax ```js math.map(x, callback) ``` ### Parameters Parameter | Type | Description --------- | ---- | ----------- `x` | Matrix &#124; Array | The matrix to iterate on. `callback` | Function | The callback method is invoked with three parameters: the value of the element, the index of the element, and the matrix being traversed. ### Returns Type | Description ---- | ----------- Matrix &#124; array | Transformed map of x ## Examples ```js math.map([1, 2, 3], function(value) { return value * value }) // returns [1, 4, 9] ``` ## See also [filter](filter.md), [forEach](forEach.md), [sort](sort.md)