Skip to content

Instantly share code, notes, and snippets.

@bhaveshdaswani93
Created November 24, 2019 05:10
Show Gist options
  • Save bhaveshdaswani93/a4c483be54c15687544c3e914bd50834 to your computer and use it in GitHub Desktop.
Save bhaveshdaswani93/a4c483be54c15687544c3e914bd50834 to your computer and use it in GitHub Desktop.
In javascript function can be passed as argument or can be return value of function execution
//Function can be passed as argument
const sing = function(name) {
return `${name} is singing a song`;
}
const letPerson = function(name,fn) {
return fn(name);
}
letperson('Lorem',sing);
// Function can be return value
const myName = function(name) {
return function() {
return `My name is ${name}`;
}
}
const whatsMyName = myName('Lorem') // this will return the function
whatsMyName();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment