Method map documentation

Returns a new array generated by the execution of a function for each item of the given array.

Example

```javascript bbn.fn.map([1, 2, 3, 4], a => { return a + 1; }); // [2, 3, 4, 5] ```

Example

```javascript bbn.fn.map( [{ name: "tools", items: [ { name: "hammers" }, { name: "screwdrivers", items: [ {name: "flat screwdrivers"}, {name: "slotted screwdrivers"}, {name: "Hex screwdrivers"}, ] } ] }, { name: "Kitchenware" }], d => { d.warranty = d.name === "Hex screwdrivers" ? "10 years" : "1 year"; return d; }, "items" ); // [ // { // name: "tools", // warranty: "1 year", // items: [ // { // name: "hammers", // warranty: "1 year", // }, { // name: "screwdrivers", // warranty: "1 year", // items: [ // {name: "flat screwdrivers", warranty: "1 year"}, // {name: "slotted screwdrivers", warranty: "1 year"}, // {name: "Hex screwdrivers", warranty: "10 year"}, // ] // } // ] // }, { // name: "Kitchenware", // warranty: "1 year" // } // ] ```

Returns a new array generated by the execution of a function for each item of the given array. - The deepProp argument is the name of property which should contain a nested array on which the function should also be applied recursively. BBN is a suite of PHP and JS libraries and VueJS components - all open-source! bbn.io, build applications, the quick way

This website uses cookies to ensure you get the best experience on our website.