Skip to content

Instantly share code, notes, and snippets.

ES6 Defaults / Overrides Pattern

Combine default parameters and destructuring for a compact version of the defaults / overrides pattern.

function foo ({ bar = 'no', baz = 'works!' }) {
  return(`${bar}, ${baz}`);
}

console.log(foo({