Skip to content

Instantly share code, notes, and snippets.

@r37r0m0d3l
Created March 24, 2018 21:19
Show Gist options
  • Select an option

  • Save r37r0m0d3l/a961b47f521308667b400b2f57c716b3 to your computer and use it in GitHub Desktop.

Select an option

Save r37r0m0d3l/a961b47f521308667b400b2f57c716b3 to your computer and use it in GitHub Desktop.
const required = () => {throw new Error('Missing parameter')};
//The below function will trow an error if either "a" or "b" is missing.
const add = (a = required(), b = required()) => a + b;
add(1, 2) //3
add(1) // Error: Missing parameter.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment