I have a method in my class that I do not want to be public. I'm wondering if it's possible to access the method from the constructor?
For example:
(function () {
var Config = function() {
this.data = this.getOptions();
var options = document.querySelector('.options');
options.addEventListener('click', this.toggleOption, false);
};
Config.prototype = function() {
var getOptions = function() {
// public method
},
toggleOption = function() {
// private method
};
return {
getOptions: getOptions
};
}();
var config = new Config();
})();
My apologies if this has been asked before, but is this possible?
toggleOptionin the outer scope, inside the IIFE, it will still be "private". But this "private" and "public" concept doesn't transfer to JS too well, not in the classical OOP sense.