Context:
This is more of styling question in hopes of writing cleaner code.
Problem:
As shown in the code below, depending on whether certain variables hold a value or not, the code uses the variable to access deeper into the object. I have a feeling that there must be a cleaner way to go about this so I'm curious to get some inputs on this. Any insights are greatly appreciated. Thank you!
Code:
if (!stageKey) { return dataRefreshSpec?.data } if (!datasetType) { return dataRefreshSpec?.data[stageKey] } return dataRefreshSpec?.data[stageKey][datasetType]