Accessing deep properties and methods of an object with using a path
If we're talking functional-programming, I'd use .forEach() instead of a for loop. It abstracts the iteration process.



if (!curProp[paths[i]]) return does not seem quite right to me, because it will work funny with falsy values. It's better to rely on object.hasOwnProperty(), or Object.keys() depending on the way you want it to work.

Example:

var obj = {};
obj["property1"] = 0;
obj["property2"] = "";

obj["property1"] ? obj["property1"] : "No property1 is available";
  // --&gt; "No property1 is available", isn't right from the humans perspective noramally

obj["property2"] ? obj["property2"] : "No property2 is available";
  // --&gt; "No property2 is available"




I think, it's always good to spell out the return value. In other words, return undefined is better than return in this function.



Slightly different variant:

function get(targetObject, targetPropertyPath) {
    const pathPartList = targetPropertyPath.split('.');
    let currentProperty = targetObject;

    pathPartList.forEach(pathPart =&gt; {
        if (!currentProperty.hasOwnProperty(pathPart)) return undefined;

        const property = currentProperty[pathPart];
        currentProperty = (typeof property !== 'function') ? property : property();
    });

    return currentProperty;
}