!DOCTYPE html html head title自定义类型/title /head body h1自定义类型/h1 script //定义一个类 class MyClass { //有参数的构造函数 constructor(a, b) { this._a a; this._b b; } } //类的原型函数定义 MyClass.prototype.GetA function (){ return this._a; } //类的原型函数定义 MyClass.prototype.GetB function() { return this._b; } /script script var myClass1 new MyClass(1, 2); var a1 myClass1.GetA(); var b1 myClass1.GetB(); console.log(a1: a1); console.log(b1: b1); /script /body /html