Created
November 24, 2019 05:10
-
-
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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//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