Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

Computed property names

//Use [] , that will be computed and used as the property name.

const key1 = "name";
const key2 = "age";
const student = {
    [key1]:"john Doe",
    [key2]:26
}
console.log(student)
//{ name:"john Doe", age:26 }
Comment

PREVIOUS NEXT
Code Example
Javascript :: map and filter js 
Javascript :: react native cli sdk.dir 
Javascript :: if else statement javascript 
Javascript :: how to get current time using moment 
Javascript :: get props from methods in vue 
Javascript :: how to add a tilemap in phaser 3 
Javascript :: download file from api response 
Javascript :: fullcalendar edit event modal react 
Javascript :: Truncate a string using javascript 
Javascript :: nextjs starter template with auth 
Javascript :: javascript mover 
Javascript :: how to change data value in jquery 
Javascript :: toast js 
Javascript :: Discord.js v13 / command handler 
Javascript :: undefined 
Javascript :: sliding puzzle javascript 
Javascript :: react redux form validation 
Javascript :: apexcharts bar onclick index 
Javascript :: what is syntactic sugar javascript 
Javascript :: table checkbox react 
Javascript :: javascript github 
Javascript :: hasChildNodes 
Javascript :: Stringy.JS 
Javascript :: react return value from component 
Javascript :: skip method js 
Javascript :: javascript cheat sheet 
Javascript :: get date format javascript 
Javascript :: jquery scroll to bottom of div 
Javascript :: jquery validate submithandler 
Javascript :: SyntaxError: Unexpected token F in JSON at position 0 
ADD CONTENT
Topic
Content
Source link
Name
1+9 =