JavaScript Patterns and Techniques discusses JavaScript fundamentals including:
- JavaScript is an implementation of EcmaScript with support varying by browser version. It is prototype-based, dynamically typed, supports first class functions, and can be used in object-oriented, functional, or imperative styles.
- Objects can be created using literals, anonymous constructors, factory methods, or wrappers. Properties can be set using dot notation, square brackets, or Object helper methods.
- Constructors, or classes, are defined using functions but must be invoked with new. Constructors set the prototype and allow for polymorphism.
- Variables scope differs in JavaScript. Private class members can be achieved through closures or
2. What exactly JS is ?
¡ñ Ecma Script implementation
Currently most browsers fully supports EcmaScript-262 5.1 http://kangax.github.io/compat-
table/es5/
Except IE8 - supports EcmaSript 3rd edition (FYI: there was not ES 4)
Previous releases http://www.ecma-international.org/publications/standards/Ecma-262.htm
¡ñ Prototype Based
¡ñ Dynamically typed
¡ñ First Class Functions
¡ñ Object Oriented, Functional, Imperative
4. Setting properties to object
¡ñ Dot Notation
¡ñ Square brackets notation
¡ñ Helper methods from Object
setting_properties1.js
5. Writing constructors aka defining Classes
¡ñ Function vs Constructor
¡ñ Function¡¯s prototype
¡ñ __proto__
¡ñ polimorphism
constructor.js
6. Privacy in Java Script
¡ñ Variables scope in JS
¡ñ Private Class Members
privacy.js, privacy2.js
7. Modules in JavaScript
Module is set of methods and properties, with
or without state.
¡ñ Simple module modules.js
¡ñ Private state in modules modules2.js
¡ñ Revealing Module Pattenr