lundi 4 avril 2016

how is this code snippet working (module pattern) (Addy Osmani)?

This is one of the code snippet that i got from the book by Addy Osmani, and could not understand how its working ?

function library(module) {
  $(function() {
    if (module.init) {
      module.init();
    }
  });
  return module;
}

var myLibrary = library(function() {
  return {
    init: function() {
      // module implementation
    }
  };
}());

Aucun commentaire:

Enregistrer un commentaire