[Solved] How to make an object into text in js


Make some kind of lookup function

var lookup = (function (o) {
    return function lookup() {
        var i, e = o, s="";
        for (i = 0; i < arguments.length; ++i) {
            s += "https://stackoverflow.com/" + arguments[i];
            if (!e.hasOwnProperty(arguments[i]))
                throw "PathNotFoundError: " + s;
            e = e[arguments[i]];
        }
        return {path: s, value: e};
    }
}(obj));

And using it

console.log(lookup('1', 'hi').path); // "/1/hi"

solved How to make an object into text in js