Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

destructure dynamic property

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 :: zero timeout javascript 
Javascript :: materialize for react 
Javascript :: query selector has clas 
Javascript :: toggle in react 
Javascript :: prop type for ref in react js 
Javascript :: js location 
Javascript :: javascript date get future 15 minutes 
Javascript :: express serve home page 
Javascript :: react router multiple path 
Javascript :: (intermediate value).getdate is not a function 
Javascript :: create react app failed with code 1 
Javascript :: jquery set width 
Javascript :: jquery select div in div 
Javascript :: json parse string 
Javascript :: angular checkbox disabled 
Javascript :: nativescript absolutelayout bottom 
Javascript :: sort javascript array 
Javascript :: is_int js 
Javascript :: get message author discord.js 
Javascript :: jquery remove focus 
Javascript :: es6 check if the object is empty 
Javascript :: how to get ip address javascript 
Javascript :: how to check if div is display none jquery 
Javascript :: how to check consecutive characters in javascript 
Javascript :: contenteditable javascript 
Javascript :: get css custom property javascript 
Javascript :: custom login with facebook button react native 
Javascript :: refresh page and run function after javascript 
Javascript :: latitude and longitude distance calculate in node js 
Javascript :: javascript check if required 
ADD CONTENT
Topic
Content
Source link
Name
7+7 =