Last active
November 15, 2019 15:06
-
-
Save rotimi-best/5e12813c7d1f0a5a298993a59b07fc79 to your computer and use it in GitHub Desktop.
Basic simple to understand how to pass a default value for a required functional argument
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
const { log } = console; | |
const run = (a) => `${a} - Run` | |
const dance = b => `${b} - Dance` | |
const defaultAction = c => `${c} - Can do all things :)` | |
const human = (action = defaultAction) => action('A human can') | |
log(human()) // A human can - Can do all things :) | |
log(human(run)) // A human can - Run | |
log(human(dance)) // A human can - Dance |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment