JavaScript
This is an old revision of this page, as edited by Ed Poor (talk | contribs) at 16:14, December 17, 2009. It may differ significantly from current revision.
JavaScript is a programming language used for web development. While it is primarily used as a scripting language, it has some object-oriented features.[1]
Lessons in scope
There are two sets of variables associated with any object you define in JavaScript.
The first set of variables defined with the this keyword, are all public. The second set of variables, defined with the var keyword, are private. You can even use the same name for a public and private variable, and JavaScript can tell them apart.
Accessing public and private variables
Use regular dot notation to get the public variables of an object
- shape.size
Within class functions, use this to get a public variable, and omit to get a private variable!
Notes
- ↑ Object Oriented Programming in JavaScript - Mike Koss