0 points

Javascript design patterns - Module pattern - Object - POO


dashboard

Wed Nov 04 2020 13:05:29 GMT+0000 (UTC)

Posted by @julien #javascript

const bookModule = (function() {
  // private
  let title = ‘JavaScript’;
  let price = 15;
  // public
  return {
    printTitle: function () {
      console.log(title);
    }
  }
})();
bookModule.printTitle(); // JavaScript
content_copy Copy

https://medium.com/javascript-in-plain-english/7-javascript-design-patterns-every-developer-should-know-df9c40e7debf