JSFiddle - React, Tailwind, and code Playground
JavaScript
function pydict (item) {
if(!(this instanceof pydict)) {
return new pydict(item);
}
var self = this;
self._item = item;
self.get = function(name, def) {
var val = self._item[name];
return new pydict(val === undefined || val === null ? def : val);
};
self.value = function() {
return self._item;
};
return self;
};
// now use it by wrapping your js object
var output = {deeply: { nested: { array: [] } } };
var array = pydict(output).get('deeply', {}).get('nested', {}).get('array', []).value();
console.log(array);