标签:
function Person(opts) { var def = { name: ‘何XX‘, age: 10, sex: ‘男‘ }; opts = $.extend(def,opts); this.name = opts.name; this.age = opts.age; this.sex = opts.sex; } Person.prototype.output= function () { console.log(this.name); };
//调用方法1: var tom = new Person({ name: "大叔", age: 2009, sex: ‘女‘ });
tom.output();
//调用方法2:
var o = new Object();
Car.call(o, "Dudu", 2010, 5000);
console.log(o.output());
标签:
原文地址:http://www.cnblogs.com/heqhbk/p/4262445.html