js的简单工厂模式

<script>
    //创建工厂
    var mbfactory={
        createbike:function () {
            return new macbike();
        }
    }
    function macbike() {}
    macbike.prototype={
        constructor:macbike,
        getmb:function () {
            console.log('hahahahahah')
        }
    }
    var gg=mbfactory.createbike();
    gg.getmb();
</script>

猜你喜欢

转载自blog.csdn.net/zerocher/article/details/75254893
今日推荐