Skip to main content


Showing posts from September, 2012

JavaScript The Good Parts - To see the real beauty of the language

    Recently, I finished reading the book "JavaScript The Good Parts" written by Douglas Crockford . Actually, many developers, although they have used JavaScript for many years, they haven't tried to learn it in a proper way. Therefore there is a great amount of poorly written codes in the world wide web. And also JavaScript said to be the world's most misunderstood programming language. So, this is a great book to read for any one who wants to see the real beauty of JavaScript. The book has ten chapters and five appendixes which describes the good and bad parts of the language, and how to manipulate the good parts, and how to avoid the bad parts. I did read the book from the first page to the last page and found there is nothing to ignore or skip without reading. And my passion about JavaScript was increased exponentially because of this book, since I found there are many workarounds to overcome the limitations of the language. After all, in

Javascript Module Pattern

Module pattern is one of the well know design patterns in JavaScript. I did read about this pattern, for the first time, in a publication done by Douglas Crockford . Since then, I have used this pattern in many occasions in my coding. Using a module, an interface can be presented, by hiding the implementation and the state of an object. And it's a way of having private attributes and methods. A simple implementation is given below. var containers = (function () {         var module = {};              var default_container_width = 500; //private property         var possible_containers_list = new Array();         possible_containers_list[1]="comments";         possible_containers_list[2]="respond";            module.list = possible_containers_list; //public property         function getContainerWidth() {//private function             // ...         }         module.hideAll = function () {//public function            // ...         };