JS module: Phantom head method(?)

The main problem I see with doing this is that you need to keep the whole prototype chain together inside the constructor (basicInfo) and that you'll only export methods binded to the final method in the chain.

The first point is bad because it will lead to large files, where a whole delegation chain is bundled up together (and nothing makes me think it has a better chance of being spaghetti-free). But when you match this with the second point, it turns out you're building a whole delegation tree which you won't be able to reuse at all. It's built up ad hoc for usage of the final exported node, on each concrete exported object. And being so, what does this delegation chain provide you?

You might consider keeping an internal "private bag", such as...

function basicInfo() {
    var private = { };
    function setName(name) { this.name = name; }
    function printName() { console.log(this.name); }

    return {
        setName: setName.bind(private),
        printName: printName.bind(private)
    };
}

...if you really feel you need to keep your private variables more tightly together. But building a whole one-time-use delegation chain seems going too far for too little benefit (if there is one at all).

/r/javascript Thread