Skip to content

Instantly share code, notes, and snippets.

@tjeastmond
Created February 20, 2019 20:42
Show Gist options
  • Save tjeastmond/b483efbc3e6884175641a13bebd928d9 to your computer and use it in GitHub Desktop.
Save tjeastmond/b483efbc3e6884175641a13bebd928d9 to your computer and use it in GitHub Desktop.
Helping someone with a JS question
function head() {
console.log("HEAD");
/* Some more logic that goes down here then will return function */
return function body(arg) {
console.log(arg);
function inner() {
console.log("INNER METHOD");
}
// return "SOMETHING USEFUL";
return { inner };
};
}
let p = head();
p("HELLO BODY"); //will print "HELLO BODY"
p("HELLO BODY 2").inner(); //will print "HELLO BODY 2"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment