JSFiddle - React, Tailwind, and code Playground

JavaScript

Object.prototype.nestedByString=function(reference){
    var current=this;
    path=reference.split(".");
    for(var i=0;i<path.length;i++){
        current=current[path[i]];
    }
    return current;
}
obj={address:{town:{street:"My Street"}}};
alert(obj.nestedByString("address.town.street"));