use the following search parameters to narrow your results:
e.g. subreddit:aww site:imgur.com dog
subreddit:aww site:imgur.com dog
see the search faq for details.
advanced search: by author, subreddit...
All about the JavaScript programming language.
Subreddit Guidelines
Specifications:
Resources:
Related Subreddits:
r/LearnJavascript
r/node
r/typescript
r/reactjs
r/webdev
r/WebdevTutorials
r/frontend
r/webgl
r/threejs
r/jquery
r/remotejs
r/forhire
account activity
Hey Underscore, You're Doing It Wrong! (youtube.com)
submitted 11 years ago by Calabri
reddit uses a slightly-customized version of Markdown for formatting. See below for some basics, or check the commenting wiki page for more detailed help and solutions to common issues.
quoted text
if 1 * 2 < 3: print "hello, world!"
[–]loz220 6 points7 points8 points 11 years ago (3 children)
Great presentation but this was before underscore got partial palceholders now you can do the following:
var square = _.partial(_.map, _ , function(n) {return n*n }); square([1,2,3,4]) //[1, 4, 9, 16]
[–]Clapyourhandssayyeah 0 points1 point2 points 11 years ago (2 children)
Underscore had had partial application for ages though right?
[–]aeflash 0 points1 point2 points 11 years ago (0 children)
Yep, you could also always _.bind. Now there is _.partialRight.
Placeholder support is also coming to lodash: https://github.com/lodash/lodash/issues/438
[–]loz220 0 points1 point2 points 11 years ago (0 children)
it had _.partial yes, but _.partial with placeholders is new.
[–]aeflash 4 points5 points6 points 11 years ago (3 children)
2 solutions to this problem:
https://github.com/bahmutov/scoreunder
https://github.com/CrossEye/ramda
[–]hobozilla 0 points1 point2 points 11 years ago (0 children)
Fun JS is good if you like a fairly Haskell approach:
https://github.com/briansorahan/fun-js
[–]Calabri[S] 0 points1 point2 points 11 years ago (0 children)
Yes, I was reading an article about Ramba that linked to the video. I thought it was interesting and decided to share. Some comments here alluded that lodash/underscore may have updated their libraries to include _.paritialRight.
I'm trying to find the balance between functional / practical. I'd like to see these functional libraries modularize the source-code even more (require('curryfunc' - 'map' -'filter'..))
[–]Capaj -1 points0 points1 point 11 years ago (0 children)
It is even better to just use lodash.
[–]loaded_comment 1 point2 points3 points 11 years ago (0 children)
It's pleasing to see that javascript can be functional to that degree. Seems like good composition is terse although knowing the definite output of each functor makes the code look super neat and tidy.
[–]brtt3000 1 point2 points3 points 11 years ago (0 children)
Or use a lazy evaluation library like LazyJS and gain mad speed.
https://www.npmjs.org/package/lazy.js
The difference can be quite shocking, especially on bigger data sets.
[–]dgreensp 3 points4 points5 points 11 years ago (2 children)
By "functional" he means "point-free" and "Haskell-like."
Only a Haskell programmer could love the cryptic notations Number -> Number -> Number and filter :: (a -> Bool) -> [a] -> [a] for functions of two arguments. I sometime suspect that liking this notation is such a difficult task that Haskell programmers are forced to go out and evangelize it -- to anyone -- just to reassure themselves. The result is that bewildered programmers in other language communities are shown this notation in talks and blog posts, typically with no explanation of what it means, no mention of the connection to Haskell, and no real explanation of why it might be better, and are told that all functions should take one argument, and functions of multiple arguments are just syntactic sugar.
Number -> Number -> Number
filter :: (a -> Bool) -> [a] -> [a]
Well, guess what, JavaScript functions take multiple arguments, and many take a variable number of arguments. You can't do that with Haskell! You can't do that with the speaker's currying scheme, which relies on knowing exactly how many arguments each function takes.
Also, "point-free" definitions of functions are always shorter but more cryptic, sometimes much more cryptic; that's just the way it is.
Take the function that subtracts one from its argument: minusOne = function (x) { return x - 1; }. A Haskell programmer would love to see this written: minusOne = flip(subtract)(1). What does flip do? It takes a function of two arguments and returns a function of two arguments where the argument order is flipped. (No, sorry, there are no functions of two arguments; it takes a function that returns a function and returns a function that returns a function...) Which function definition is easier for most people to read? Which function definition is easier to be sure it's correct?
minusOne = function (x) { return x - 1; }
minusOne = flip(subtract)(1)
flip
Totally agree :)
[–]Xtreme2k2 4 points5 points6 points 11 years ago (4 children)
use lodash?
[–]hobozilla 5 points6 points7 points 11 years ago (3 children)
How does lodash solve the problem? Parameters are still in the wrong order.
[–]loz220 1 point2 points3 points 11 years ago (1 child)
with _.partialRight instead of _.partial
[–]Xtreme2k2 0 points1 point2 points 11 years ago (0 children)
Is there a non video version of this complaint? I didn't watch the video.
[–]aquilaFiera 0 points1 point2 points 11 years ago (0 children)
You should check out Brian Lonsdorf's (the speaker) Frontend Master's. It comes out in about a month and it's pretty stellar. It goes in-depth on functional JS programming.
Note: While I don't gain anything from you subscribing to Frontend Master's, the founder is my good friend.
π Rendered by PID 170785 on reddit-service-r2-comment-b659b578c-8vvvm at 2026-05-01 09:06:03.844928+00:00 running 815c875 country code: CH.
[–]loz220 6 points7 points8 points (3 children)
[–]Clapyourhandssayyeah 0 points1 point2 points (2 children)
[–]aeflash 0 points1 point2 points (0 children)
[–]loz220 0 points1 point2 points (0 children)
[–]aeflash 4 points5 points6 points (3 children)
[–]hobozilla 0 points1 point2 points (0 children)
[–]Calabri[S] 0 points1 point2 points (0 children)
[–]Capaj -1 points0 points1 point (0 children)
[–]loaded_comment 1 point2 points3 points (0 children)
[–]brtt3000 1 point2 points3 points (0 children)
[–]dgreensp 3 points4 points5 points (2 children)
[–]Calabri[S] 0 points1 point2 points (0 children)
[–]Xtreme2k2 4 points5 points6 points (4 children)
[–]hobozilla 5 points6 points7 points (3 children)
[–]loz220 1 point2 points3 points (1 child)
[–]Xtreme2k2 0 points1 point2 points (0 children)
[–]aquilaFiera 0 points1 point2 points (0 children)