标签:
1.工厂模式
1 function createPerson(name, age, job) { 2 var o = new Object(); 3 o.name = name; 4 o.age = age; 5 o.job = job; 6 o.sayName = function () { 7 console.log(this.name); 8 } 9 return o; 10 } 11 12 var person1 = createPerson(‘Nick‘, 20, ‘worker‘); 13 var person2 = createPerson(‘Greg‘, 30, ‘Doctor‘);
2.
标签:
原文地址:http://www.cnblogs.com/gemicat/p/4810921.html