免费视频淫片aa毛片_日韩高清在线亚洲专区vr_日韩大片免费观看视频播放_亚洲欧美国产精品完整版

打開APP
userphoto
未登錄

開通VIP,暢享免費電子書等14項超值服

開通VIP
js四大繼承方式

1、繼承方式一:原型鏈

Grand.prototype.lastName = 'kj';

     function Grand(){

         this.wife = 'xh';

     }

    Father.prototype= new Grand();

     function Father(){

         this.name = 'gx';

     }

     Son.prototype= new Father();

     function Son(){

        this.name = 'lk';

     }

     var son = new Son();

2、繼承方式二: 構(gòu)造函數(shù)(通過call())

function Person(name,age){

         this.name = name;

         this.age = age;

     }

     function Student(name,age,grade){

        Person.call(this,name,age);

         this.grade = grade;

     }

     function Miny(name,age,grade,sex){

         Student.call(this,name,age,grade);

         this.sex = sex;

     }

     var mingy = new Miny('wang',16,17,'nan');

     function A(){

         this.m1='aaa';

     }

     function B(){

         A.call(this);

     }

     var w=new B();

3、第三種方式:共享原型

Father.prototype.age = 30;

     function Father(){

     }

     function Son(){

     }

     Son.prototype = Father.prototype;

     var son = new Son();

     var father = new Father();

4、第四種方式:圣杯模式

person.prototype.name = 'huluwa';

function person(){

}

function student(){

}

//媒介

function inherit(person,student){

function f(){}

f.prototype =  person.prototype;

student.prototype = new f();

student.prototype.constructor = student;

student.prototype.super = person.prototype;

}

inherit(person,student)

var student = new student();

//繼承

person.prototype = {

name : 'huluwa';

age : 17;

}

function person(){

}

student.prototype = new person();

function student(){}

var stu = new student();

本站僅提供存儲服務(wù),所有內(nèi)容均由用戶發(fā)布,如發(fā)現(xiàn)有害或侵權(quán)內(nèi)容,請點擊舉報。
打開APP,閱讀全文并永久保存 查看更多類似文章
猜你喜歡
類似文章
Javascript之面向?qū)ο蟪绦蛟O(shè)計(一)
生活服務(wù)
分享 收藏 導(dǎo)長圖 關(guān)注 下載文章
綁定賬號成功
后續(xù)可登錄賬號暢享VIP特權(quán)!
如果VIP功能使用有故障,
可點擊這里聯(lián)系客服!

聯(lián)系客服