Get value of child object’s using a variable referencing that key


I have below object and I can reference key e as in the following:

var obj = {
"id": 100,
"date": "2021",
"d": "D",
"e": {
    "e1": "E"
},
"f": {
    "f1": "F"
}}

console.log(obj.e); // returning { e1: 'E' }

I want to get the value by using the object key as below and input [Key] always be a that place.

{
"d": "D",
"e": "E",
"f": "HardCode FF"
}

How can I do this?

Source: JavaSript – Stack Overflow

December 3, 2021
Category : News
Tags: javascript

Leave a Reply

Your email address will not be published. Required fields are marked *

Sitemap | Terms | Privacy | Cookies | Advertising

Senior Software Developer

Creator of @LzoMedia I am a backend software developer based in London who likes beautiful code and has an adherence to standards & love's open-source.