NewStats: 3,263,953 , 8,182,072 topics. Date: Monday, 09 June 2025 at 02:41 AM 263i4w

6z3e3g

Javascript Gurus Get In Here Biko - Programming - Nairaland 1v3166

Javascript Gurus Get In Here Biko (396 Views)

(4)

(1) (Go Down)

crunchyDope(m): 3:59pm On Sep 21, 2020
Question /Expectation

Lets say this is a json


config:
{
subconfig:
{
target :{

}

}
}


normally i would do

var value = json.config.subconfig.target;


buh how do i get it using a string
like so eval("json" + "config" + "subconfig" + "target"wink?

<i might be in the wrong prof>
Karleb(m): 5:20pm On Sep 21, 2020
Why would you want to do that?
crunchyDope(m): 6:59pm On Sep 21, 2020
Karleb:
Why would you want to do that?

because the json format might change and i want d code to adapt..

lets say d api is nested 3 levels and suddenly its 4 levels , how do i change d value seeing as d code is still doing ..

json[levelA][levelB][levelC]= "value"

now if the json is now under another object, the code would fail

Karleb(m): 7:15pm On Sep 21, 2020
crunchyDope:


because the json format might change and i want d code to adapt..

lets say d api is nested 3 levels and suddenly its 4 levels , how do i change d value seeing as d code is still doing ..

json[levelA][levelB][levelC]= "value"

now if the json is now under another object, the code would fail


Why would the configuration file change?

If I'm not mistaken, config file should be one of the easiest to set up.

Why not create a separate config file for the new changes?

What is stopping you from having a database.js, mail.js, session.js, cache.js, whatnot.js... Under a config directory?
crunchyDope(m): 7:19pm On Sep 21, 2020
Karleb:


Why would the configuration file change?

If I'm not mistaken, config file should be one of the easiest to set up.

Why not create a separate config file for the new changes?

What is stopping you from having a database.js, mail.js, session.js, cache.js, whatnot.js... Under a config directory?



too much js, too much to manage.
also m querying an api and i dont think its reliable

(1) (Reply)

A Complete Guide On How To Hire Reactjs Development Company

(Go Up)

Sections: How To . 12
Disclaimer: Every Nairaland member is solely responsible for anything that he/she posts or s on Nairaland.