前言

大家好 我是歌谣 今天给大家带来继承知识的讲解 今天姚说的第一个知识点就是原型链继承

代码部分

<!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>

运行结果

继承之原型链继承_原型链