原型插件 prototype
时间:2015-01-30 17:32:00
收藏:0
阅读:187
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());
评论(0)