Last active
May 23, 2021 19:55
-
-
Save MilosPaunovic/64e34aa9e29d6c6316346f11a785dcf7 to your computer and use it in GitHub Desktop.
Default parameter validation using method
This file contains hidden or 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 isRequired = () => { | |
throw new Error('Parameter is required'); | |
}; | |
const print = (num = isRequired()) => { | |
console.log(`Printing number ${num}`); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment