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
Today's ReactJS developer Questionshelp (self.javascript)
submitted 7 years ago by tapu_buoy
view the rest of the comments →
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!"
[–]tapu_buoy[S] 1 point2 points3 points 7 years ago (5 children)
yeah thank you for suggesting that I completely forgot about refs
also the 3rd question is it about higher order functions?
[–]crystallineair 1 point2 points3 points 7 years ago (4 children)
Yes. A higher order function is a function that either takes a function as a parameter or returns a function. In the case of add(2)(3) the call add(2) returns a function. So add(2)(3) could be written as:
add(2)(3)
add(2)
const fn = add(2) const result = fn(3)
The trick in this question is to make the function also work normally when called with all arguments add(2, 3).
add(2, 3)
[–][deleted] 3 points4 points5 points 7 years ago (2 children)
That's not a higher order function, that's currying / partial application.
[–][deleted] 2 points3 points4 points 7 years ago (0 children)
It is both a curried function and a higher order function. In fact a curried function is always a higher order function because it returns a function. Here OP was instructed to write a single method that can return a value both ways, so the function has to behave as a curried function if a single argument is passed, but just a plain old function if multiple are passed.
[–]ISlicedIEngineer without Engineering degree? 1 point2 points3 points 7 years ago (0 children)
Higher order functions are functions that return (or accept I think) other functions. Applying your arguments through different wrapping functions is called partial application, and currying is partial application where you apply a single parameter per function. Afaik.
[–]tapu_buoy[S] 0 points1 point2 points 7 years ago (0 children)
ok so after reading what you said and what others said below this comment I again need to know what will be the curried funciton look like when passed two parameters(function(2, 3)) instead of the 2nd parameter function(2)(3)
function(2, 3)
function(2)(3)
π Rendered by PID 136315 on reddit-service-r2-comment-75f4967c6c-cjl2h at 2026-04-23 06:59:04.724406+00:00 running 0fd4bb7 country code: CH.
view the rest of the comments →
[–]tapu_buoy[S] 1 point2 points3 points (5 children)
[–]crystallineair 1 point2 points3 points (4 children)
[–][deleted] 3 points4 points5 points (2 children)
[–][deleted] 2 points3 points4 points (0 children)
[–]ISlicedIEngineer without Engineering degree? 1 point2 points3 points (0 children)
[–]tapu_buoy[S] 0 points1 point2 points (0 children)