Create Javascript Library


I would like to know how I can create my own javascript library, that is, create functions that can be reused in several projects and with easy customization.

I know there are already several very good libraries out there (JQuery for example), but this question is only for my learning and growth as a professional, I believe it will be of great help for others as well.

Thank you so much.


I think a good start would be to study the Module pattern.

See an example:

var Counter = (function(){
  var count = 0;

  return {
      count: function() {
        return count;

    , increment: function() {
        return count += 1;

Counter.increment(); // Imprime: 1
Counter.increment(); // Imprime: 2
Counter.increment(); // Imprime: 3
Scroll to Top