If There Is No Property When Destructuring an Object

·

1 min read

An error does not occur, and 'undefined' is assigned.

const obj = {};

const { k } = obj;

console.log(k); // undefined