ES6 Object Destructuring Default Parameters

Yes. You can use “defaults” in destructuring as well:

(function test({a = "foo", b = "bar"} = {}) {
  console.log(a + " " + b);
})();

This is not restricted to function parameters, but works in every destructuring expression.

Leave a Comment