Skip to content

Instantly share code, notes, and snippets.

@NateJLewis
Last active August 22, 2016 05:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save NateJLewis/2ca667dd8a94185fbcc686d0101c05e3 to your computer and use it in GitHub Desktop.
Save NateJLewis/2ca667dd8a94185fbcc686d0101c05e3 to your computer and use it in GitHub Desktop.
Playing with higher-order functions.
function makeConcatenater ( left ) {
return function ( right ) {
return left + ' ' + right;
}
}
var addString = makeConcatenater ( 'Hello' );
addString( 'World' );
///////////////////////////////
function makeAdder ( left ) {
return function ( right ) {
return left + right;
}
}
var add5 = makeAdder( 5 );
add5(20)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment