Skip to content

Instantly share code, notes, and snippets.

@rijkvanzanten
Created November 2, 2016 10:28
Show Gist options
  • Save rijkvanzanten/cae60c9b3b873b206d46f279f817a8ac to your computer and use it in GitHub Desktop.
Save rijkvanzanten/cae60c9b3b873b206d46f279f817a8ac to your computer and use it in GitHub Desktop.
Required function params
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