Skip to content

Instantly share code, notes, and snippets.

@vldvel
Last active April 20, 2018 07:30
Show Gist options
  • Save vldvel/e4b6fd0e8edab5d0b05275f2cf53f2bc to your computer and use it in GitHub Desktop.
Save vldvel/e4b6fd0e8edab5d0b05275f2cf53f2bc to your computer and use it in GitHub Desktop.
lodash reduce vs native reduce
const numbers = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10];
const timerDateReduceLodash = new Date();
console.log('lodash reduce', reduce(numbers, (sum, n) => sum + n, 0));
console.log('lodash time', new Date() - timerDateReduceLodash);
const timerDateReduceJS = new Date();
console.log('native reduce', numbers.reduce((sum, n) => sum + n, 0));
console.log('native time', new Date() - timerDateReduceJS);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment