Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

destructure dynamic properties

let object = {x: 3, y: 6}
let propertyName = 'x'

// the value of the destructured property is assigned to a new variable
let {[propertyName]: value} = object

console.log(value) // 3
 
PREVIOUS NEXT
Tagged: #destructure #dynamic #properties
ADD COMMENT
Topic
Name
9+1 =