JS Tip: You can declare a default value when destructuring
JS Tip: You can declare a default value when destructuring.
Example:
const { id = 7 } = {}
console.log(id) // 7
This protects from setting "id" above to undefined. And you don’t have to declare a separate null check. 👍
#javascript