Skip to content

Instantly share code, notes, and snippets.

@PatrickJS
Last active September 19, 2023 07:00
Show Gist options
  • Save PatrickJS/5462522 to your computer and use it in GitHub Desktop.
Save PatrickJS/5462522 to your computer and use it in GitHub Desktop.
Write a function that adds from two invocations in JavaScript
function addf(x) {
return function(y) {
return x + y;
}
}
addf(3)(4)
-------------------------
function addf(x) {
var func = function(y) {
return x + y;
}
return func;
}
addf(3)(4)
@sarir-karim
Copy link

Nice explanation

@MantasUrb
Copy link

thanks for explanation! :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment