JSFiddle - React, Tailwind, and code Playground
HTML
<script src="https://getfirebug.com/firebug-lite-debug.js"></script>
JavaScript
var thing = {
//first nested object
nested1:{
//nested object within nested1
moreNested1:{
//some values
a:1,
b:2
}
},
//second nested object
nested2:{
//nested object within nested2
moreNested2:{
//some values
x:1,
y:2,
//the function that accesses a and b from moreNested1
foo:function() {
//code that does not work
var a = thing.nested1.moreNested1.a;
var b = thing.nested1.moreNested1.b;
//logs a and b
console.log('hey');
console.log("a is " + a + " and b is " + b);
}
}
}
};
thing.nested2.moreNested2.foo();