Method Array.mapFunction
Call a function on every member of an array
-
Syntax
undefined Array.mapFunction(Function f )
This method will call the functionfon every member in the array. Each member is passed to the functionfas its first argument. -
Parameters
Function f- The function to call on the array members
-
Return value
No explicit return value. Default value of
undefinedis returned. -
Examples
- To check that all members of an array is a number
// Define array var a = [1,2,3,4]; // Define function function checkNumber(x) { if (typeof x != 'number') throw new Error('Member not a number.'); } // Call function on all members a.mapFunction(checkNumber);
- Related Array.mapMethod
-
Download
Source
Unless otherwise noted all code in the JSLab Standard Library is licensed as GPLv3. See http://www.gnu.org/licenses/gpl.html for the entire license.
