1. <strong id="7actg"></strong>
    2. <table id="7actg"></table>

    3. <address id="7actg"></address>
      <address id="7actg"></address>
      1. <object id="7actg"><tt id="7actg"></tt></object>

        Spring data jpa 時間注解

        共 1216字,需瀏覽 3分鐘

         ·

        2020-08-23 18:27

        來源:SegmentFault 思否
        作者:大牛哥




        先定義一個構造函數(shù):


        function Person(name,age){    this.name = name;    this.age = age;    this.say = function(){        console.log("hello world")    }}Person.prototype.gender = male;


        1.原型鏈繼承:將子類的構造函數(shù)的原型變?yōu)楦割惖膶嵗龑ο?/span>


        Student.prototype = new Person();Student.prototype.constructor = Student


        優(yōu)點:實現(xiàn)簡單
        缺點:無法向父構造函數(shù)傳參


        2.通過構造函數(shù)繼承


        function Student(name,age){    Person.call(this,name,age)    this.name = name;    this.age = age;    this.say = function(){        console.log("hello world")    }}


        缺點:無法訪問父構造函數(shù)的原型中的方法


        3.將子構造函數(shù)的原型修改為父構造函數(shù)的原型


        function Student(name,age){    Person.call(this,name,age)    this.name = name;    this.age = age;    this.say = function(){        console.log("hello world")    }}Student.prototype = Person.prototypeStudent.prototype.constructor = Student


        缺點:破壞了原型鏈,給子類的原型添加屬性父類原型也會添加


        4.將子類的原型設置為父類的實例對象

        function Student(name,age){    Person.call(this,name,age)    this.name = name;    this.age = age;    this.say = function(){        console.log("hello world")        }    }  Student.prototype = new Person();


        缺點:調(diào)用了兩次父類構造函數(shù),消耗內(nèi)存





        點擊左下角閱讀原文,到?SegmentFault 思否社區(qū)?和文章作者展開更多互動和交流。

        -?END -

        瀏覽 45
        點贊
        評論
        收藏
        分享

        手機掃一掃分享

        分享
        舉報
        評論
        圖片
        表情
        推薦
        點贊
        評論
        收藏
        分享

        手機掃一掃分享

        分享
        舉報
        1. <strong id="7actg"></strong>
        2. <table id="7actg"></table>

        3. <address id="7actg"></address>
          <address id="7actg"></address>
          1. <object id="7actg"><tt id="7actg"></tt></object>
            欧美污视频网站 | 青草视频在线观看免费 | 国产情侣自拍露脸到高潮 | 久久偷拍无码 | 国产精品高潮呻吟久久av无 | 天天干天天日天天射 | 日韩欧美视频在线播放 | av一区二区三区四区 | 亚洲精品蜜桃 | 黑人的巨物挺进了我的身体视频 |