If There Is No Property When Destructuring an Object

Aug 2, 2022·

1 min read

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

const obj = {};

const { k } = obj;

console.log(k); // undefined