News for hackers. Stuff that matters.
Re:Lists of JavaScript methods which you can use natively by frostik on Friday July 01, 2016 @06:47AM (#12015028)
There's a huge gotcha: _.map, _.forech, ... can iterate over objects (often used as associative arrays) - Native map can't.

At some point you'll need lodash and co again - at least for convinience.

Re:Lists of JavaScript methods which you can use natively by avolcano on Friday July 01, 2016 @07:41AM (#12015247)
Yup, this is my biggest issue with JavaScript's built-in functional utilities. It just totally ignores treating objects like dictionaries/maps. Even ES6 Maps/Sets lack functional features.

There's a strawman proposal out there to solve this but until then I'll be sticking with Lodash: https://github.com/leebyron/ecmascript-iterator-hof

Re:Lists of JavaScript methods which you can use natively by runarberg on Friday July 01, 2016 @12:13PM (#12017343)
We already have Object.keys()[1], and Object.values()[2] and Object.entries()[3] are in the stage 4 proposal[4] and should be safe to polyfill.

[1]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Refe...

[2]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Refe...

[3]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Refe...

[4]: https://github.com/tc39/proposal-object-values-entries

Re:Lists of JavaScript methods which you can use natively by DrJokepu on Friday July 01, 2016 @07:04AM (#12015092)
Object.keys() is rather well supported these days though.
Re:Lists of JavaScript methods which you can use natively by frostik on Friday July 01, 2016 @07:18AM (#12015153)
Yes, but means that you need to implement map, foreach, filter yourself. So you might be better off with lodash.
Re:Lists of JavaScript methods which you can use natively by mullsork on Friday July 01, 2016 @07:41AM (#12015244)
I think he's referring to `Object.keys(object).reduce`. We polyfill `Object.entries` so we do `Object.entries(object).reduce((result, [key, value]) => ...)`
Re:Lists of JavaScript methods which you can use natively by crucialfelix on Friday July 01, 2016 @07:39AM (#12015237)
Related:

for (var key of Object.keys(imps)) { }

I figured that would work with babel-2015 and it did work on Chrome and Safari but on Firefox visitors were getting:

Symbol.Iterator undefined

You need http://babeljs.io/docs/plugins/transform-es2015-for-of/ as well.

So there is much less risk in using _.each(imps, (value, key) => and not having to discover what you don't know.

I also added Firefox to the unit tests after that.

Re:Lists of JavaScript methods which you can use natively by jacobr on Friday July 01, 2016 @08:50AM (#12015560)
And Object.values is supported in Chrome and Firefox, and has polyfills for other browsers.
Re:Lists of JavaScript methods which you can use natively by connorjburton on Friday July 01, 2016 @09:14AM (#12015725)
I think this is what makes Lodash so convenient, I just want expected functions like _.forEach to work with whatever I throw at it.
Re:Lists of JavaScript methods which you can use natively by jdd on Friday July 01, 2016 @10:41AM (#12016372)
Re:Lists of JavaScript methods which you can use natively by jkd3v on Friday July 01, 2016 @08:34AM (#12015469)
Furthermore, lodash/underscore contain some null object patterns: null.map(...) will throw an error, while _.map(null, ...) returns []
Re:Lists of JavaScript methods which you can use natively by frenchie4111 on Friday July 01, 2016 @07:44AM (#12015259)
I agree, this is the sole reason I use atleast underscore in every project.
Re:Lists of JavaScript methods which you can use natively by swang on Friday July 01, 2016 @12:12PM (#12017334)
the repo already points that out.

>Important: Note that the native equivalents are array methods, and will not work with objects. If this functionality is needed, then Lodash/Underscore is the better option.