var config = {
a: 'test',
b: {
c: // SOmeway to access config a value
}
}
IS there any way to access value from class b?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Neither of those things is a class. They’re objects.
No, there’s no way to access
config.awhere you havec:in your code, all within the same object literal. You can do it after the fact:Note that
config.b.cwill receive the value ofconfig.a. If someone updatesconfig.alater,config.b.cwill not be updated.If
cwere a function, you could accessconfig.afrom within it:There, each time you call
c, you’ll be using the current value ofconfig.a.