Posted by & filed under Uncategorized.

As more and more applications rely heavily on Javascript for functionality and control, the importance of modular, structured and testable javascript become primary. Although frameworks such as Angular JS, Backbone, Knockout and the like abstract much of the logic from JS programing, there is still a need for clear patterns in Javascript development. I’ve been working with OO programing in Javascript for a few years now and have a few pointers that may help the uninitiated.

Let’s walk through a simple application and learn about some of the high level concepts. Let’s say I wanted to develop an application to play tic-tac-toe, and to keep it light, I wanted to do it all on the client side.

 function square()
  {
    var public = {
      setMark: function(letter){
        private.letter = letter;
      }
    };

    var priavte = {
      letter: null
    };

    return public; 

  }