js继承注意的地方

    function Father() {

        this.LastName = "Xu",

           this.GetLastName = function () {

               alert(this.LastName);

           }

    }



    var Mother = {

        Address: "XXXXXXX",

        GetAddress: function () {

            alert(this.Address);

        }

    }



    function Son() {

        this.FirstName = "Eason";

    }

    Son.prototype = new Father();

    Son.prototype.__proto__ = Mother;

    var s = new Son();

    s.GetLastName();

    s.GetAddress();

    alert(s.LastName);

如果Son不是function 是对象 就不能这样些,而父类是function的时候是怎么写,要注意区分

你可能感兴趣的:(js)