We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
No description provided.
The text was updated successfully, but these errors were encountered:
JS继承方式有很多,主要分ES5和ES6继承的实现 先说一下ES5是如何实现继承的 ES5实现继承主要是基于prototype来实现的,具体有三种方式
function B(name,age) { A.call(this,name,age) }
组合继承是结合第一种和第二种方式 再说一下ES6是如何实现继承的 ES6继承是目前比较新,并且主流的集成方式,用class定义类,用extends继承类,用super()表示父类 例如: 创建A类
class A{ constructor(){ //构造器代码,new时自动执行 } 方法一(){//A类的方法} 方法二(){//A类的方法} }
创建B类并继承A类
class B extends A{ constructor(){ super()//表示父类 } }
实例化B类
var b1=new B() b1.方法一()
Sorry, something went wrong.
No branches or pull requests
No description provided.
The text was updated successfully, but these errors were encountered: