工厂模式创建对象
使用工程模式可以快速大量的创建拥有相同属性和行为的对象
<code>
function createGirlFriend(a){
return {
name: a,
eat: function(){
console.log("吃");
}
};
}
var girl1 = createGirlFriend("二雷");
var girl2 = createGirlFriend("三雷");
</code>
使用工程模式可以快速大量的创建拥有相同属性和行为的对象
<code>
function createGirlFriend(a){
return {
name: a,
eat: function(){
console.log("吃");
}
};
}
var girl1 = createGirlFriend("二雷");
var girl2 = createGirlFriend("三雷");
</code>
本文标题:js多种的多种模式
本文链接:https://www.haomeiwen.com/subject/zyshvttx.html
网友评论