I am trying to clean up my code as well as make it more generic for reuse. And would like to know if what I am attempting is possible.
I have a what will be a large array of objects which subsequently have more object arrays inside.
These arrays are easily navigated to as seen in the example, but I wanted to abbreviate the generic part into a variable to reuse.
var widgetObject = [];
thisWidget = "widgetObject.xReport";
widgetObject["xReport"] = {
id: "xReport",
widgetTitleHeading: "x Report Heading",
widgetFilters: {
startDate: "01/01/2018",
endDate: "01/01/2018"
},
widgetAttributes: {
xPos: "0",
yPos: "0",
width: "5",
height: "5"
}
};
console.log(widgetObject.xReport.widgetFilters.startDate);
//this will not work.
console.log(thisWidget.widgetFilters.startDate);
My question here is, is it possible to create an abbreviated string like I am trying to with 'thisWidget' in the example somehow?