Created
November 2, 2016 10:28
-
-
Save rijkvanzanten/cae60c9b3b873b206d46f279f817a8ac to your computer and use it in GitHub Desktop.
Required function params
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 required = function(paramName) { | |
throw new Error(`${paramName} is required`); | |
}; | |
const foo = function((param1 = required('param1')), param2) { | |
// ... | |
}; | |
foo(); // Error: param1 is required |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment