prototype

来源:互联网 发布:罗马共和国知乎 编辑:程序博客网 时间:2024/05/21 17:25
function Person(name){    this.name = name;}Person.prototype.getname = function () {    return this.name;}var ObjectFactory = function () {    var obj = new Object(),        Constructor = [].shift.call(arguments);    obj.__proto__ = Constructor.prototype;    var ret = Constructor.apply(obj, arguments);    return typeof ret === 'object' ? ret : obj;};var a = ObjectFactory(Person, 'seven');
原创粉丝点击