mirror of
https://github.com/josdejong/mathjs.git
synced 2026-01-18 14:59:29 +00:00
721 B
721 B
Function forEach
Iterate over all elements of a matrix/array, and executes the given callback function.
Syntax
math.forEach(x, callback)
Parameters
| Parameter | Type | Description |
|---|---|---|
x |
Matrix | Array | The matrix to iterate on. |
callback |
Function | The callback function is invoked with three parameters: the value of the element, the index of the element, and the Matrix/array being traversed. |
Examples
var math = mathjs();
math.forEach([1, 2, 3], function(value) {
console.log(value);
});
// outputs 1, 2, 3