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.
More Related Contents:
- Understanding members of Symbol – function constructor
- Find list of strings that matches a pattern that start with a special character « and end with a special character »
- Unable to access React instance (this) inside event handler [duplicate]
- Is it possible to import modules from all files in a directory, using a wildcard?
- Why does babel rewrite imported function call to (0, fn)(…)?
- How to import jquery using ES6 syntax?
- Spread Syntax ES6
- Async function not returning value, but console.log() does: how to do? [duplicate]
- What does the @ mean inside an import path?
- let keyword in the for loop
- What does three dots do in ReactJS [duplicate]
- What are the actual uses of ES6 WeakMap?
- Why are ES6 classes not hoisted?
- Javascript ES6 cross-browser detection
- Can I set the filename of a PDF object displayed in Chrome?
- How to find duplicate values in a JavaScript array of objects, and output only unique values?
- When should I use brackets with imports
- How do I make a “public static field” in an ES6 class?
- es6 import for side effects meaning
- Mixins for ES6 classes, transpiled with babel
- Get list of duplicate objects in an array of objects
- What is the difference between importing a function expression or a function declaration from a ES6 module?
- destructuring falsy and null with default parameters
- What can we do with ES6 Generator that we cannot with for loop?
- Error: How to serialize data from getStaticProps : Next.js
- Update one of the objects in array, in an immutable way
- Is it possible to export Arrow functions in ES6/7?
- Return object with default values from an array in JavaScript
- Deep nested array of objects not rendering
- ES6 module syntax: is it possible to `export * as Name from …`?