Complete the code to rename the key 'name' to 'fullName' in the object.
const person = { name: 'Alice', age: 30 };
const { name: [1] } = person;
console.log(fullName);Using name: fullName renames the key name to fullName when destructuring.
Complete the code to rename the key 'age' to 'years' when destructuring.
const user = { age: 25, city: 'NY' };
const { age: [1] } = user;
console.log(years);The syntax age: years renames the age property to years in the destructured variable.
Fix the error in the destructuring assignment to rename 'title' to 'bookTitle'.
const book = { title: '1984', author: 'Orwell' };
const { [1] } = book;
console.log(bookTitle);The correct syntax to rename a key during destructuring is oldKey: newKey. So title: bookTitle is correct.
Fill both blanks to rename 'firstName' to 'name' and 'birthYear' to 'year' in the object.
const person = { firstName: 'John', birthYear: 1990 };
const { [1], [2] } = person;
console.log(name, year);Use firstName: name and birthYear: year to rename keys during destructuring.
Fill all three blanks to rename keys 'a' to 'alpha', 'b' to 'beta', and 'c' to 'gamma' in the object.
const obj = { a: 1, b: 2, c: 3 };
const { [1], [2], [3] } = obj;
console.log(alpha, beta, gamma);Each key is renamed using oldKey: newKey syntax during destructuring.