— Anyways, that's the two ways I know of to shim private vars
— It seems we both surprise each other right now! XD
— Nothing outside this scope has access to the weakmap, hence private vars
— Anyways, what you said makes sense, that the new keyword would not neccesarily introduce any bad things or cons.
Message permanent page
— Although just doing closures is way easier
— It always is. More developers should take advantage of (abuse!) JS scoping rules
—
const createInstance = function () {
const priv = { value: 42 };
return {
digitSum () { ... }
};
};