JavaScript 객체 비구조화에서 변수 이름 지정
변수 이름이 객체 키 이름과 일치하지 않도록 할 수 있습니다:
let obj = {
year: 2025,
month: 12,
day: 31,
};
let {year: y, month: m, day: d} = obj;
console.log(y); // 2025를 출력합니다
console.log(m); // 12를 출력합니다
console.log(d); // 31를 출력합니다
다음 코드에서는 객체의 일부가 해당 변수에 기록됩니다:
let options = {
color: 'red',
width: 400,
height: 500,
};
let c = options.color;
let w = options.width;
let h = options.height;
학습한 이론에 따라 비구조화를 통해 이 코드를 수정하십시오.