Took me a lot of time to frame the title, alas it's still hard to comprehend.
Anyway this is what I wanna do, but don't know how to do it, or whether it is even possible, so please enlighten me.
Here it is:
const defaults = {
backgroundcolor: '#000',
color: '#fff',
getProps: [
'some value',
`${this.backgroundcolor}`,
`${this.color}`
]
};
I know I can call it outside of the Object like defaults.backgroundcolor
, but I wanna know if the above code is achievable too? Thanks in advance.
this
does not have the value you want it to have inside a static declaration. Javascript doesn't work that way. You can assigndefaults.getProps
after you've declared the object and then you can refer to other properties in the object. – jfriend00 yesterday