代码部分
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>原型链继承</title> </head> <body> <script> function FatherType(){ this.fathertype=true } FatherType.prototype.getFatherValue=function(){ return this.fathertype } function SonType(){ this.sontype=false } SonType.prototype=new FatherType(); SonType.prototype.getSonValue=function(){ return this.sontype } var geyao=new SonType(); console.log(geyao.getFatherValue ()) </script> </body> </html>
运行结果