The first type:
// The 1th kind of notation function Circle (r) { this. R = r;} Circle. PI = 3.14159; Circlefunction() { return circle. PI * THIS.R * this. R;} var New Circle (1.0); Alert (c
The second type:
// 2nd notation Circle = function () { var obj = new object (); Obj . pi = 3.14159; Obj . area = function (R) { return this. pi * r * R; return obj;} var C = new Circle (); alert (c . Area (1.0));
The third type:
// The 3rd kind of notation var New Object (); Circle. PI = 3.14159; Circlefunction(r) { return this. PI * R * r;} Alert (Circle. Area (1.0));
The fourth type:
// The 4th kind of notation var circle={ "PI": 3.14159, "area":function(r) { return ). PI * R * r; }; Alert (CircleArea (1.0));
The fifth type:
// The 5th kind of notation var New Function ("this.") PI = 3.14159;this.area = function (r) {return r*r*this. PI;} " ); alert ((new Circle ()). Area (1.0));
Five kinds of syntax for JS object-oriented