1 | Objects are defined with the function statement. The following Circle object, for example, has property r: function Circle( r ) { this.r = ( r > 0 ) ? r : 0; } |
2 | 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; |