If the last argument to a function is a destructured object 
with at least one having a default value, makie it `{}` by default.

For example:

```js
function doSomething ({ a: true }) {
  console.log(a)
}
doSomething({ a: false }) // OK
doSomething() // fails because the object is undefined

// solution
function doSomething ({ a: true } = {}) {
  console.log(a)
}
```

I find that for complex objects (such as options to methods), 
having to make the argument’s default value `{}` in every
function declaration inconvenient.

Let me know your feedback / comments.

Regards
Jorge Bucaran
_______________________________________________
es-discuss mailing list
es-discuss@mozilla.org
https://mail.mozilla.org/listinfo/es-discuss

Reply via email to