简体   繁体   中英

Replace key name by its value

 todo = {
"1.CoverLetterPage":"Hello",
    "3.JoiningDate":"Any Day",
    '4.Location':'Texas',
    '6.Leave':'AnyDay',
 };

I have called the list of keys in the list

done=[1.CoverLetterPage,4.Location,"3.JoiningDate,6.Leave]

What if i want to replace the values in the list 'done' by its value by typescript

Use map function to obtain values from todo object and overwrite done .

this.done = this.done.map( v => this.todo[v] )

Also your done array values should be in string form with qoutes around them like below:

done=['1.CoverLetterPage','4.Location','3.JoiningDate','6.Leave']

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM