DEV Community

Discussion on: 4 Ways to Level-Up Your JS Destructuring and Spread Syntax

Collapse
 
jonrandy profile image
Jon Randy 🎖️ • Edited

Nice! Some advanced stuff I'd never considered here. If you combine it with metho-number you could even do stuff like this:

const {[bin]: binary, [hex]: hexidecimal, [base(8)]: octal} = 16

console.log(binary) // "10000"
console.log(hexidecimal) // "10"
console.log(octal) // "20"
Enter fullscreen mode Exit fullscreen mode
Collapse
 
scottodea profile image
Scott O'Dea

Cool! Taken it to overdrive. Although, I'd say this relates to my last point about code readability. Nice for personal projects but a pain when someone pulls you aside to ask what is going on with the line of code.

Collapse
 
jonrandy profile image
Jon Randy 🎖️

Yeah - WTFs per minute in a code review of that would likely be off the charts