model.js

var Model = {

inherited: function  () {},

created: function () {},

prototype: {
	init: function (attrs){
		if(attrs){
			this.load(attrs);
		}
	},

	load: function  (attrs) {
		for(var name in attrs){
			this[name] = attrs[name];
		}
	}
},

create: function (){
	var object = Object.create(this);
	object.parent = this;
	object.prototype = object.fn = Object.create(this.prototype);

	object.created();
	this.inherited(object);
	return object;
},

init: function(){
	var instance = Object.create(this.prototype);
	instance.parent = this;
	instance.init.apply(instance, arguments);
	return instance;
},

find: function  () {
	
},

extend: function  (o) {
	var extended = o.extended;
	
}

}

var Asset = Model.create();
var User = Model.create();

var user = User.init();

原文地址:https://www.cnblogs.com/lanse-yan/p/3977701.html