SlideShare a Scribd company logo
1 of 30
Download to read offline
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

What's hot

スマートフォン勉強会@関東 #11 LT 5分で語る SQLite暗号化
スマートフォン勉強会@関東 #11 LT 5分で語る SQLite暗号化スマートフォン勉強会@関東 #11 LT 5分で語る SQLite暗号化
スマートフォン勉強会@関東 #11 LT 5分で語る SQLite暗号化
Taro Matsuzawa
 
WhereCamp EU talk: iPhone location 101
WhereCamp EU talk: iPhone location 101WhereCamp EU talk: iPhone location 101
WhereCamp EU talk: iPhone location 101
Michael Dales
 
Provisionamento orquestrado nas nuvens com Juju
Provisionamento orquestrado nas nuvens com JujuProvisionamento orquestrado nas nuvens com Juju
Provisionamento orquestrado nas nuvens com Juju
Thiago Rondon
 
Huong dan cai dat hadoop
Huong dan cai dat hadoopHuong dan cai dat hadoop
Huong dan cai dat hadoop
Quỳnh Phan
 

What's hot (18)

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

Similar to You Don't Need Lodash

Using jQuery to Extend CSS
Using jQuery to Extend CSSUsing jQuery to Extend CSS
Using jQuery to Extend CSS
Chris Coyier
 
From mysql to MongoDB(MongoDB2011北京交流会)
From mysql to MongoDB(MongoDB2011北京交流会)From mysql to MongoDB(MongoDB2011北京交流会)
From mysql to MongoDB(MongoDB2011北京交流会)
Night Sailer
 

Similar to You Don't Need Lodash (20)

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

Recently uploaded

XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
ssuser89054b
 
Kuwait City MTP kit ((+919101817206)) Buy Abortion Pills Kuwait
Kuwait City MTP kit ((+919101817206)) Buy Abortion Pills KuwaitKuwait City MTP kit ((+919101817206)) Buy Abortion Pills Kuwait
Kuwait City MTP kit ((+919101817206)) Buy Abortion Pills Kuwait
jaanualu31
 
Standard vs Custom Battery Packs - Decoding the Power Play
Standard vs Custom Battery Packs - Decoding the Power PlayStandard vs Custom Battery Packs - Decoding the Power Play
Standard vs Custom Battery Packs - Decoding the Power Play
Epec Engineered Technologies
 
Integrated Test Rig For HTFE-25 - Neometrix
Integrated Test Rig For HTFE-25 - NeometrixIntegrated Test Rig For HTFE-25 - Neometrix
Integrated Test Rig For HTFE-25 - Neometrix
Neometrix_Engineering_Pvt_Ltd
 
Hospital management system project report.pdf
Hospital management system project report.pdfHospital management system project report.pdf
Hospital management system project report.pdf
Kamal Acharya
 
scipt v1.pptxcxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx...
scipt v1.pptxcxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx...scipt v1.pptxcxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx...
scipt v1.pptxcxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx...
HenryBriggs2
 
1_Introduction + EAM Vocabulary + how to navigate in EAM.pdf
1_Introduction + EAM Vocabulary + how to navigate in EAM.pdf1_Introduction + EAM Vocabulary + how to navigate in EAM.pdf
1_Introduction + EAM Vocabulary + how to navigate in EAM.pdf
AldoGarca30
 
Query optimization and processing for advanced database systems
Query optimization and processing for advanced database systemsQuery optimization and processing for advanced database systems
Query optimization and processing for advanced database systems
meharikiros2
 

Recently uploaded (20)

XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
 
Convergence of Robotics and Gen AI offers excellent opportunities for Entrepr...
Convergence of Robotics and Gen AI offers excellent opportunities for Entrepr...Convergence of Robotics and Gen AI offers excellent opportunities for Entrepr...
Convergence of Robotics and Gen AI offers excellent opportunities for Entrepr...
 
Kuwait City MTP kit ((+919101817206)) Buy Abortion Pills Kuwait
Kuwait City MTP kit ((+919101817206)) Buy Abortion Pills KuwaitKuwait City MTP kit ((+919101817206)) Buy Abortion Pills Kuwait
Kuwait City MTP kit ((+919101817206)) Buy Abortion Pills Kuwait
 
8th International Conference on Soft Computing, Mathematics and Control (SMC ...
8th International Conference on Soft Computing, Mathematics and Control (SMC ...8th International Conference on Soft Computing, Mathematics and Control (SMC ...
8th International Conference on Soft Computing, Mathematics and Control (SMC ...
 
Electromagnetic relays used for power system .pptx
Electromagnetic relays used for power system .pptxElectromagnetic relays used for power system .pptx
Electromagnetic relays used for power system .pptx
 
Standard vs Custom Battery Packs - Decoding the Power Play
Standard vs Custom Battery Packs - Decoding the Power PlayStandard vs Custom Battery Packs - Decoding the Power Play
Standard vs Custom Battery Packs - Decoding the Power Play
 
Integrated Test Rig For HTFE-25 - Neometrix
Integrated Test Rig For HTFE-25 - NeometrixIntegrated Test Rig For HTFE-25 - Neometrix
Integrated Test Rig For HTFE-25 - Neometrix
 
Introduction to Geographic Information Systems
Introduction to Geographic Information SystemsIntroduction to Geographic Information Systems
Introduction to Geographic Information Systems
 
Employee leave management system project.
Employee leave management system project.Employee leave management system project.
Employee leave management system project.
 
Path loss model, OKUMURA Model, Hata Model
Path loss model, OKUMURA Model, Hata ModelPath loss model, OKUMURA Model, Hata Model
Path loss model, OKUMURA Model, Hata Model
 
Computer Graphics Introduction To Curves
Computer Graphics Introduction To CurvesComputer Graphics Introduction To Curves
Computer Graphics Introduction To Curves
 
Post office management system project ..pdf
Post office management system project ..pdfPost office management system project ..pdf
Post office management system project ..pdf
 
Computer Networks Basics of Network Devices
Computer Networks  Basics of Network DevicesComputer Networks  Basics of Network Devices
Computer Networks Basics of Network Devices
 
Hospital management system project report.pdf
Hospital management system project report.pdfHospital management system project report.pdf
Hospital management system project report.pdf
 
scipt v1.pptxcxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx...
scipt v1.pptxcxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx...scipt v1.pptxcxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx...
scipt v1.pptxcxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx...
 
COST-EFFETIVE and Energy Efficient BUILDINGS ptx
COST-EFFETIVE  and Energy Efficient BUILDINGS ptxCOST-EFFETIVE  and Energy Efficient BUILDINGS ptx
COST-EFFETIVE and Energy Efficient BUILDINGS ptx
 
1_Introduction + EAM Vocabulary + how to navigate in EAM.pdf
1_Introduction + EAM Vocabulary + how to navigate in EAM.pdf1_Introduction + EAM Vocabulary + how to navigate in EAM.pdf
1_Introduction + EAM Vocabulary + how to navigate in EAM.pdf
 
Signal Processing and Linear System Analysis
Signal Processing and Linear System AnalysisSignal Processing and Linear System Analysis
Signal Processing and Linear System Analysis
 
Ground Improvement Technique: Earth Reinforcement
Ground Improvement Technique: Earth ReinforcementGround Improvement Technique: Earth Reinforcement
Ground Improvement Technique: Earth Reinforcement
 
Query optimization and processing for advanced database systems
Query optimization and processing for advanced database systemsQuery optimization and processing for advanced database systems
Query optimization and processing for advanced database systems
 

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!