Skip to content

Instantly share code, notes, and snippets.

@MilosPaunovic
Last active May 23, 2021 19:55
Show Gist options
  • Save MilosPaunovic/64e34aa9e29d6c6316346f11a785dcf7 to your computer and use it in GitHub Desktop.
Save MilosPaunovic/64e34aa9e29d6c6316346f11a785dcf7 to your computer and use it in GitHub Desktop.
Default parameter validation using method
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