Javascript-форум (https://javascript.ru/forum/)
-   Элементы интерфейса (https://javascript.ru/forum/dom-window/)
-   -   Паттерн «Модуль» (https://javascript.ru/forum/dom-window/73970-pattern-modul.html)

s24344 01.06.2018 15:19

Паттерн «Модуль»
 
Здравствуйте, подскажите пожалуйста, как в следующем коде вызвать отдельный метод
const app = (function() {

  // private

  const init = function() {};

  // public

  return {

    init: function() {

      const _this = this;

      _this.projectInit(); // как в данном случае вызвать только один метод? (либо firstHandler(), либо secondHandler())

    },

    projectInit: function () {

      const firstHandler = function () {
        alert('firstHandler');
      }

      const secondHandler = function () {
        alert('secondHandler');
      }

    }

  };

})();

app.init();


Часовой пояс GMT +3, время: 10:46.