mercredi 4 janvier 2017

revealing module vs object literal pattern on encapsulation

I usually do component for each feature, says I have abc feature I will create below js

var AbcComponent = (function(){}
   var initialize = function(){

   },
   privateMethod1 = function(){

   };

   return {init:initialize}
)();

and include in app.js, with AbcComponent.init();. Few days ago I ready about OO using object literal pattern and I doubt my own writing style.

How can literal pattern encapsulate scope since javascript is function scope?

Aucun commentaire:

Enregistrer un commentaire