is there a way to access a nested property within an object without knowing its path? For instance I could have something like this
let test1 = {
location: {
state: {
className: 'myCalss'
}
}
};
let test2 = {
params: {
className: 'myCalss'
}
};
Is there neat way to 'extract' className property?
I have a solution but it's pretty ugly, and it accounts just for this two cases, I was wondering if there is something more flexible I could do
Here's a somewhat elegant approach to creating nested property getters:
If you want to prevent cyclical objects from causing a stack overflow, I suggest using a
WeakSetto keep track of iterated object references: