JSFiddle - React, Tailwind, and code Playground
by Gajus Kuizinas
HTML
<script src="https://rawgit.com/lodash/lodash/530bf7df9f869b7bc030f2936b79ff8799b14db3/lodash.js"></script>
JavaScript
var products,
derivePrice1,
derivePrice2;
products = [
{price: 1},
{price: 1},
{price: 1}
];
derivePrice1 = function (product) {
console.log('Deriving price 1.');
product.price += Math.random();
return product;
};
derivePrice2 = function (product) {
console.log('Deriving price 2.');
product.price -= Math.random();
return product;
};
products = _(products)
.map(derivePrice1)
.map(derivePrice2);
console.log('derivePrice1 and derivePrice2 are not called until products.value() is called.');
products.value()