These examples shows to JavaScript programmers coming from standard OOP languages how to achieve encapsulation in JavaScript.
To try these examples, just download the gist on your local computer and open the .html files.
Alternatively, you can play with these examples online via jsbin.com:
- Encapsulation in javascript - method 1a/3
- Encapsulation in javascript - method 1b/3
- Encapsulation in javascript - method 2/3
- Encapsulation in javascript - method 3/3
... you can also run them via bl.ocks.org: