拓冰建站拓冰建站
首页 / 资讯中心 / 正文

(前端)3.js自定义类样例

!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
分享:

看完干货,该让你的企业上线了

免费需求沟通 · 48 小时内出具建站方案 · 河南本地可上门