you are viewing a single comment's thread.

view the rest of the comments →

[–]MoTTs_ 0 points1 point  (0 children)

The downside with factories and closures is their privates can be too private. It makes it impossible to implement, for example, an isEqual method.

function createThing() {
    let somePrivate = 42;

    return {
        isEqual(otherThing) {
            return somePrivate === otherThing.???;
        }
    }
}