js中的原型 prototype

<script>
    /**
     * prototype  原型
     */
    //原型的使用方式
    function Fn() {//给函数的prototype增加的属性值
        Fn.prototype.name = '王福朋';
        Fn.prototype.getYear = function () {
            return 1988;
        };
    }

    Fn.prototype.name = "王福明";
    Fn.prototype.getYear = function () {
        return 1988;
    }
    var fn = new Fn();

</script>

猜你喜欢

转载自blog.csdn.net/weixin_37839711/article/details/79012285