JavaScript Notes
Coming from the Java background, my main problem with JavaScript is encapsulation: global space is not good. I love OO because object is the best place to encapsulate the data. Here are the patterns I would like to follow always. In the JavaScript, function can be used as : function method constructors classes Module As a first example, will start with the Module. Module Pattern In this pattern, you can define number of privilege method which have access to the secret information such as private variables and methods . For example, setFirstName method can set the name local variable as well as the function getUserFullName has access to the private method getFullName as shown int he following code: var person = ( function (firstName, lastName, age) { //properties var a = age; var fname = firstName; var lname = lastName; //common functions function getFullName (f,l) { return fname+ " " +lname; } return { //open to outside ...