JS Coding Questions Logo
JS Coding Questions
#365💼 Interview💻 Code

What is destructuring aliases

Advertisement

728x90

Sometimes you would like to have a destructured variable with a different name than the property name. In that case, you'll use a : newName to specify a name for the variable. This process is called destructuring aliases.

javascript
1const obj = { x: 1 };
2  // Grabs obj.x as as { otherName }
3
4const { x: otherName } = obj;

Advertisement

Responsive Ad
🎯 Practice NowRelated Challenge

JavaScript Coding Exercise 22

Test your knowledge with this interactive coding challenge.

Start Coding

Advertisement

728x90
365of476