日期:2014-05-16 浏览次数:20399 次
function createPersonFactory(name, age, sex) { var Person = new Object(); Person.name = name; Person.age = age; Person.sex = sex; Person.run = function() { alert(Person.name + " is running!"); } return Person; } var person1 = createPersonFactory("redhacker", 20, "男"); var person2 = createPersonFactory("wendy", 18, "女"); alert(person1.name + "," + person1.age + "," + person1.sex); alert(person2.name + "," + person2.age + "," + person2.sex); person1.run(); person2.run();