Objects are defined with the function statement. The following Circle object, for example, has property r: function Circle( r ) { this.r = r || 1.0; } |
The this keyword permits this function to be used as a constructor: var c = new Circle( 2.0 ); var area = Math.PI * c.r * c.r; |