I have an JavaScript library that implements "private fields" with closures, along the lines of:
function makePublicInterface()
{
var private = 17;
return {
foo: function() { console.log(private); }
};
}
and I have an object returned by that function:
var public = makePublicInterface();
Is there a way, given 'public', to somehow access 'private'? Chrome devtool certainly can, but I don't see a way to do it programmatically, there is nothing in either Object or Function to do that.
This is purely a language question, I can add an accessor method to this particular library just fine.