DEV Community

Discussion on: JavaScript Destructuring.

Collapse
 
jonrandy profile image
Jon Randy 🎖️

Variable names used in destructuring can also be dynamic:

const {length, [length-1]: last} = "Hello!"
console.log(length)  // 6
console.log(last)  // '!'
Enter fullscreen mode Exit fullscreen mode
Collapse
 
frankymolina profile image
FrankyMolina

Thank you for showing that use! 🔥