Search
 
SCRIPT & CODE EXAMPLE
 

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
Comment

Destructuring objects by extracting properties of variables with dynamic values

const myTitle= 'title';

const myObject = {title: 'My Title', name: 'My Name'};
const {[myTitle]: myObjectTitle} = myObject;

console.log(myObjectTitle); // "My Title"
Comment

PREVIOUS NEXT
Code Example
Javascript :: could not resolve module fs react native 
Javascript :: scrollview refresh 
Javascript :: react native position text in center of view 
Javascript :: js select element by css selector 
Javascript :: find the max length of string elements in an array 
Javascript :: material ui align icon with text 
Javascript :: javascript date get nearest 15 minutes 
Javascript :: react native get mac address 
Javascript :: regex contains string in end 
Javascript :: draw line in javascript 
Javascript :: convert hex code to rgb javascript 
Javascript :: javascript get element position relative to document 
Javascript :: export aab react native 
Javascript :: javascript parse json string 
Javascript :: javascript add function to onchange event 
Javascript :: electron get exe path 
Javascript :: get cursor position in contenteditable div 
Javascript :: settimeout inside loop 
Javascript :: bignumber to number javascript 
Javascript :: how could you implement javascript into java 
Javascript :: javascript class 
Javascript :: .textcontent 
Javascript :: how to remove an element from a parent element javascript 
Javascript :: count no of punctuation in string in js 
Javascript :: jquery migrate 
Javascript :: js spread exclude property 
Javascript :: javascript append element to array 
Javascript :: js ajax receive html 
Javascript :: giving an html element own attribute using js 
Javascript :: how to check if website is down javascript 
ADD CONTENT
Topic
Content
Source link
Name
3+6 =