SlideShare a Scribd company logo
YOU DON’T NEED
LODASH**PROBABLY
WHAT IS LODASH?
“A modern JavaScript utility library…”
https://lodash.com
IT’S GOT SOMETHING FOR EVERYONE!
map, reduce, filter, forEach
IT’S GOT SOMETHING FOR EVERYONE!
map, reduce, filter, forEach, find, includes, contains
IT’S GOT SOMETHING FOR EVERYONE!
map, reduce, filter, forEach, find, includes, contains,
key, toUpper, toLower, join, compact, concat, flatten
IT’S GOT SOMETHING FOR EVERYONE!
map, reduce, filter, forEach, find, includes, contains,
key, toUpper, toLower, join, compact, concat, flatten,
clone, head, tail, groupBy, size, isArray, isDate, isEqual,
and on and on…
USING LODASH
const _ = require(‘lodash’);
const x = [ 1, 2, 3 ];
const doubled = _.map(x, (num) => 2 * num);
console.log(doubled); // [ 2, 4, 6 ]
BUT WAIT… map IS ALREADY AN ARRAY METHOD!
const x = [ 1, 2, 3 ];
const doubled = x.map((num) => 2 * num);
console.log(doubled); // [ 2, 4, 6 ]
BUT WAIT… map IS ALREADY AN ARRAY METHOD!
const x = [ 1, 2, 3 ];
const doubled = x.map((num) => 2 * num);
console.log(doubled); // [ 2, 4, 6 ]
No need to require lodash!
!
ES5 HAS SOME (FUN)CTIONAL ARRAY METHODS
▸ Supported in Chrome, Edge, FF, IE9, Opera, Safari
▸ map
▸ filter
▸ reduce
▸ forEach
map
const x = [ 1, 2, 3 ];
const map1 = _.map(x, (num) => num * 2);
const map2 = x.map((num) => num * 2);
// [ 2, 4, 6 ]
filter
const x = [ 1, 2, 3 ];
const filter1 = _.filter(x, (num) => num > 1);
const filter2 = x.filter((num) => num > 1);
// [ 2, 3 ]
reduce
const x = [ 1, 2, 3 ];
const sum1 = _.reduce(x, (acc, num) => acc + num, 0);
const sum2 = x.reduce((acc, num) => acc + num, 0);
// 6
forEach
const x = [ 1, 2, 3 ];
_.forEach(x, (num) => console.log(num));
x.forEach((num) => console.log(num));
// 1
// 2
// 3
THAT WAS FUN, RIGHT?
It gets even more fun with ES6!
▸ Array find, includes
▸ Object merge, keys, values
find
const users = [
{ 'user': 'barney', 'age': 36, 'active': true },
{ 'user': 'fred', 'age': 40, 'active': false },
{ 'user': 'pebbles', 'age': 1, 'active': true }
];
const found1 = _.find(users, (user) => user.age > 30);
const found2 = users.find((user) => user.age > 30);
// { user: 'barney', age: 36, active: true }
includes
const x = [ 1, 2, 3 ];
const included1 = _.includes(x, 1);
const included2 = x.includes(1);
// true
merge
const obj1 = { a: 1 };
const obj2 = { b: 2 };
// avoid mutation using empty object as target
const merged1 = _.merge({}, obj1, obj2);
const merged2 = Object.assign({}, obj1, obj2);
// { a: 1, b: 2 }
keys
z = { a: 1, b: 2};
const keys1 = _.keys(z);
const keys2 = Object.keys(z);
// [ 'a', 'b' ]
values
z = { a: 1, b: 2};
const values1 = _.values(z);
const values2 = Object.values(z);
// [ 1, 2 ]
THE GOOD NEWS!
▸ Node.js 6 supports 97% of ES6!
▸ Don’t need lodash for µservices!
THE BAD NEWS…
Not all browsers are ES6 compliant.
I’M LOOKING AT YOU INTERNET EXPLORER!
POLYFILLS SAVE THE DAY!
▸ Babel can polyfill ES6 functionality
▸ meo-frontend is already doing this! !
WHAT IS SUPPORTED BY EACH BROWSER?
▸ Check the ES6 compatibility table here
HOW CAN I LEARN MORE?
▸ MDN has great documentation!
WHAT IF I REALLY NEED A LODASH FUNCTION?
Lodash lets you import just a single function!
const groupBy = require('lodash/groupby');
const data = [
{ artist: '2 Chainz', genre: 'rap'},
{ artist: 'Popcaan', genre: 'dancehall' },
{ artist: 'Kendrick Lamar', genre: 'rap' },
{ artist: 'Vybz Kartel', genre: 'dancehall' }
];
const grouped = groupBy(data, 'genre');
const groupBy = require('lodash/groupby');
const data = [
{ artist: '2 Chainz', genre: 'rap'},
{ artist: 'Popcaan', genre: 'dancehall' },
{ artist: 'Kendrick Lamar', genre: 'rap' },
{ artist: 'Vybz Kartel', genre: 'dancehall' }
];
const grouped = groupBy(data, 'genre');
console.log(grouped);
// {
// rap: [
// { artist: '2 Chainz', genre: 'rap' },
// { artist: 'Kendrick Lamar', genre: 'rap' }],
// dancehall: [
// { artist: 'Popcaan', genre: 'dancehall' },
// { artist: 'Vybz Kartel', genre: 'dancehall' }]
// }
IN SUMMARY
ES5 and ES6 are powerful and should reduce/remove your need for
Lodash!
IN SUMMARY
ES5 and ES6 are powerful and should reduce/remove your need for
Lodash!
But if you need to use a Lodash function, import just the one you need!
QUESTIONS?
COMMENTS?

More Related Content

PDF
PuppetCamp SEA 1 - Version Control with Puppet
PDF
OSCON 2009 Lightning Talk
PDF
Puppet Camp Amsterdam 2015: Manifests of Future Past
PDF
Phishing for Root (How I Got Access to Root on Your Computer With 8 Seconds o...
KEY
puppet @techlifecookpad
PDF
Couchdb
PDF
Node.js - Demnächst auf einem Server in Ihrer Nähe
PPTX
Cookies
PuppetCamp SEA 1 - Version Control with Puppet
OSCON 2009 Lightning Talk
Puppet Camp Amsterdam 2015: Manifests of Future Past
Phishing for Root (How I Got Access to Root on Your Computer With 8 Seconds o...
puppet @techlifecookpad
Couchdb
Node.js - Demnächst auf einem Server in Ihrer Nähe
Cookies

What's hot (18)

KEY
My life as a beekeeper
KEY
Perl on Amazon Elastic MapReduce
PPTX
19. CodeIgniter imagini in mysql
PDF
GOTO 2011 preso: 3x Hadoop
PPT
Drush Productivity FTW - DUG @ Krimson
PPTX
Leveraging jQuery's Special Events API (JSConf 2012)
PPTX
PDF
スマートフォン勉強会@関東 #11 LT 5分で語る SQLite暗号化
PDF
DataMapper @ RubyEnRails2009
PPTX
Php Basics part 1
PDF
GeoMapper, Python Script for Visualizing Data on Social Networks with Geo-loc...
PDF
Neoito — *NIX kungfu for web devs
PDF
Elasticsearch sur Azure : Make sense of your (BIG) data !
ZIP
WhereCamp EU talk: iPhone location 101
PDF
Provisionamento orquestrado nas nuvens com Juju
ODT
Huong dan cai dat hadoop
PDF
New collections in JS: Map, Set, WeakMap, WeakSet - WarsawJS Meetup #25
PDF
Vagrant
My life as a beekeeper
Perl on Amazon Elastic MapReduce
19. CodeIgniter imagini in mysql
GOTO 2011 preso: 3x Hadoop
Drush Productivity FTW - DUG @ Krimson
Leveraging jQuery's Special Events API (JSConf 2012)
スマートフォン勉強会@関東 #11 LT 5分で語る SQLite暗号化
DataMapper @ RubyEnRails2009
Php Basics part 1
GeoMapper, Python Script for Visualizing Data on Social Networks with Geo-loc...
Neoito — *NIX kungfu for web devs
Elasticsearch sur Azure : Make sense of your (BIG) data !
WhereCamp EU talk: iPhone location 101
Provisionamento orquestrado nas nuvens com Juju
Huong dan cai dat hadoop
New collections in JS: Map, Set, WeakMap, WeakSet - WarsawJS Meetup #25
Vagrant
Ad

Similar to You Don't Need Lodash (20)

PPTX
Introduction to MongoDB for C# developers
PPT
Batteries included: Advantages of an End-to-end solution
PDF
PHP Tips & Tricks
PDF
JSDC 2014 - functional java script, why or why not
PDF
Using jQuery to Extend CSS
PDF
React Native Evening
PDF
A Scala Corrections Library
PDF
[FT-7][snowmantw] How to make a new functional language and make the world be...
KEY
An introduction to CouchDB
PDF
Elixir - GDG - Nantes
PDF
Making JavaScript Libraries More Approachable
PDF
Latinoware
PDF
Rob Sullivan at Heroku's Waza 2013: Your Database -- A Story of Indifference
PDF
42: Rise of the dependent types
PDF
JavaScript for Flex Devs
PDF
Spark DataFrames for Data Munging
PPT
PHP and MySQL
PDF
MongoDB Aggregation Framework in action !
PPTX
5 Tips for Better JavaScript
PDF
From mysql to MongoDB(MongoDB2011北京交流会)
Introduction to MongoDB for C# developers
Batteries included: Advantages of an End-to-end solution
PHP Tips & Tricks
JSDC 2014 - functional java script, why or why not
Using jQuery to Extend CSS
React Native Evening
A Scala Corrections Library
[FT-7][snowmantw] How to make a new functional language and make the world be...
An introduction to CouchDB
Elixir - GDG - Nantes
Making JavaScript Libraries More Approachable
Latinoware
Rob Sullivan at Heroku's Waza 2013: Your Database -- A Story of Indifference
42: Rise of the dependent types
JavaScript for Flex Devs
Spark DataFrames for Data Munging
PHP and MySQL
MongoDB Aggregation Framework in action !
5 Tips for Better JavaScript
From mysql to MongoDB(MongoDB2011北京交流会)
Ad

Recently uploaded (20)

PDF
Mohammad Mahdi Farshadian CV - Prospective PhD Student 2026
PDF
Digital Logic Computer Design lecture notes
PPT
Project quality management in manufacturing
PDF
Mitigating Risks through Effective Management for Enhancing Organizational Pe...
PPTX
MET 305 2019 SCHEME MODULE 2 COMPLETE.pptx
PPTX
MCN 401 KTU-2019-PPE KITS-MODULE 2.pptx
PPTX
Recipes for Real Time Voice AI WebRTC, SLMs and Open Source Software.pptx
PDF
Well-logging-methods_new................
PPTX
Sustainable Sites - Green Building Construction
PPTX
CYBER-CRIMES AND SECURITY A guide to understanding
DOCX
ASol_English-Language-Literature-Set-1-27-02-2023-converted.docx
PDF
Embodied AI: Ushering in the Next Era of Intelligent Systems
PPTX
Geodesy 1.pptx...............................................
PPTX
Engineering Ethics, Safety and Environment [Autosaved] (1).pptx
PDF
Enhancing Cyber Defense Against Zero-Day Attacks using Ensemble Neural Networks
PDF
Operating System & Kernel Study Guide-1 - converted.pdf
PPTX
Foundation to blockchain - A guide to Blockchain Tech
PPTX
OOP with Java - Java Introduction (Basics)
PPTX
Construction Project Organization Group 2.pptx
PDF
July 2025 - Top 10 Read Articles in International Journal of Software Enginee...
Mohammad Mahdi Farshadian CV - Prospective PhD Student 2026
Digital Logic Computer Design lecture notes
Project quality management in manufacturing
Mitigating Risks through Effective Management for Enhancing Organizational Pe...
MET 305 2019 SCHEME MODULE 2 COMPLETE.pptx
MCN 401 KTU-2019-PPE KITS-MODULE 2.pptx
Recipes for Real Time Voice AI WebRTC, SLMs and Open Source Software.pptx
Well-logging-methods_new................
Sustainable Sites - Green Building Construction
CYBER-CRIMES AND SECURITY A guide to understanding
ASol_English-Language-Literature-Set-1-27-02-2023-converted.docx
Embodied AI: Ushering in the Next Era of Intelligent Systems
Geodesy 1.pptx...............................................
Engineering Ethics, Safety and Environment [Autosaved] (1).pptx
Enhancing Cyber Defense Against Zero-Day Attacks using Ensemble Neural Networks
Operating System & Kernel Study Guide-1 - converted.pdf
Foundation to blockchain - A guide to Blockchain Tech
OOP with Java - Java Introduction (Basics)
Construction Project Organization Group 2.pptx
July 2025 - Top 10 Read Articles in International Journal of Software Enginee...

You Don't Need Lodash

  • 2. WHAT IS LODASH? “A modern JavaScript utility library…” https://lodash.com
  • 3. IT’S GOT SOMETHING FOR EVERYONE! map, reduce, filter, forEach
  • 4. IT’S GOT SOMETHING FOR EVERYONE! map, reduce, filter, forEach, find, includes, contains
  • 5. IT’S GOT SOMETHING FOR EVERYONE! map, reduce, filter, forEach, find, includes, contains, key, toUpper, toLower, join, compact, concat, flatten
  • 6. IT’S GOT SOMETHING FOR EVERYONE! map, reduce, filter, forEach, find, includes, contains, key, toUpper, toLower, join, compact, concat, flatten, clone, head, tail, groupBy, size, isArray, isDate, isEqual, and on and on…
  • 7. USING LODASH const _ = require(‘lodash’); const x = [ 1, 2, 3 ]; const doubled = _.map(x, (num) => 2 * num); console.log(doubled); // [ 2, 4, 6 ]
  • 8. BUT WAIT… map IS ALREADY AN ARRAY METHOD! const x = [ 1, 2, 3 ]; const doubled = x.map((num) => 2 * num); console.log(doubled); // [ 2, 4, 6 ]
  • 9. BUT WAIT… map IS ALREADY AN ARRAY METHOD! const x = [ 1, 2, 3 ]; const doubled = x.map((num) => 2 * num); console.log(doubled); // [ 2, 4, 6 ] No need to require lodash! !
  • 10. ES5 HAS SOME (FUN)CTIONAL ARRAY METHODS ▸ Supported in Chrome, Edge, FF, IE9, Opera, Safari ▸ map ▸ filter ▸ reduce ▸ forEach
  • 11. map const x = [ 1, 2, 3 ]; const map1 = _.map(x, (num) => num * 2); const map2 = x.map((num) => num * 2); // [ 2, 4, 6 ]
  • 12. filter const x = [ 1, 2, 3 ]; const filter1 = _.filter(x, (num) => num > 1); const filter2 = x.filter((num) => num > 1); // [ 2, 3 ]
  • 13. reduce const x = [ 1, 2, 3 ]; const sum1 = _.reduce(x, (acc, num) => acc + num, 0); const sum2 = x.reduce((acc, num) => acc + num, 0); // 6
  • 14. forEach const x = [ 1, 2, 3 ]; _.forEach(x, (num) => console.log(num)); x.forEach((num) => console.log(num)); // 1 // 2 // 3
  • 15. THAT WAS FUN, RIGHT? It gets even more fun with ES6! ▸ Array find, includes ▸ Object merge, keys, values
  • 16. find const users = [ { 'user': 'barney', 'age': 36, 'active': true }, { 'user': 'fred', 'age': 40, 'active': false }, { 'user': 'pebbles', 'age': 1, 'active': true } ]; const found1 = _.find(users, (user) => user.age > 30); const found2 = users.find((user) => user.age > 30); // { user: 'barney', age: 36, active: true }
  • 17. includes const x = [ 1, 2, 3 ]; const included1 = _.includes(x, 1); const included2 = x.includes(1); // true
  • 18. merge const obj1 = { a: 1 }; const obj2 = { b: 2 }; // avoid mutation using empty object as target const merged1 = _.merge({}, obj1, obj2); const merged2 = Object.assign({}, obj1, obj2); // { a: 1, b: 2 }
  • 19. keys z = { a: 1, b: 2}; const keys1 = _.keys(z); const keys2 = Object.keys(z); // [ 'a', 'b' ]
  • 20. values z = { a: 1, b: 2}; const values1 = _.values(z); const values2 = Object.values(z); // [ 1, 2 ]
  • 21. THE GOOD NEWS! ▸ Node.js 6 supports 97% of ES6! ▸ Don’t need lodash for µservices!
  • 22. THE BAD NEWS… Not all browsers are ES6 compliant. I’M LOOKING AT YOU INTERNET EXPLORER!
  • 23. POLYFILLS SAVE THE DAY! ▸ Babel can polyfill ES6 functionality ▸ meo-frontend is already doing this! !
  • 24. WHAT IS SUPPORTED BY EACH BROWSER? ▸ Check the ES6 compatibility table here
  • 25. HOW CAN I LEARN MORE? ▸ MDN has great documentation!
  • 26. WHAT IF I REALLY NEED A LODASH FUNCTION? Lodash lets you import just a single function! const groupBy = require('lodash/groupby'); const data = [ { artist: '2 Chainz', genre: 'rap'}, { artist: 'Popcaan', genre: 'dancehall' }, { artist: 'Kendrick Lamar', genre: 'rap' }, { artist: 'Vybz Kartel', genre: 'dancehall' } ]; const grouped = groupBy(data, 'genre');
  • 27. const groupBy = require('lodash/groupby'); const data = [ { artist: '2 Chainz', genre: 'rap'}, { artist: 'Popcaan', genre: 'dancehall' }, { artist: 'Kendrick Lamar', genre: 'rap' }, { artist: 'Vybz Kartel', genre: 'dancehall' } ]; const grouped = groupBy(data, 'genre'); console.log(grouped); // { // rap: [ // { artist: '2 Chainz', genre: 'rap' }, // { artist: 'Kendrick Lamar', genre: 'rap' }], // dancehall: [ // { artist: 'Popcaan', genre: 'dancehall' }, // { artist: 'Vybz Kartel', genre: 'dancehall' }] // }
  • 28. IN SUMMARY ES5 and ES6 are powerful and should reduce/remove your need for Lodash!
  • 29. IN SUMMARY ES5 and ES6 are powerful and should reduce/remove your need for Lodash! But if you need to use a Lodash function, import just the one you need!