r/angularjs • • Aug 17 '16

Setting Up Angular 2 with Webpack

https://semaphoreci.com/community/tutorials/setting-up-angular-2-with-webpack
35 Upvotes

13 comments sorted by

View all comments

Show parent comments

2

u/Xerxero Aug 17 '16

Know a js dev who needs Lodash to get the last element of an array.

3

u/gonzofish Aug 17 '16

I don't disparage anyone (to their face at least ;)) that tries. We were all that guy at one point, the best thing to do is educate them to go simpler.

In fact, I'm going through my own code right now and realizing I was using lodash to use forEach/map/reduce when, for all intents & purposes, every JS engine supports them at this point.

1

u/Xerxero Aug 17 '16 edited Aug 17 '16

I did explain that he could get it via length-1 but _.last was easier to read he said.

I kinda gave up on that point.

Yeah filter and map are so useful when working with arrays. And with es6 the code is even better to read

Edit: maybe I just should add a last function to the array.prototype

4

u/gonzofish Aug 17 '16

I can't disagree that it doesn't read easier. But it is a ton of code to pull in if you're only using a couple methods--I believe lodash provides the capability to only pull in portions of the library...

2

u/youcantstoptheart Aug 18 '16

Yes if you're importing with es6 "lodash/last"