function ActiveRecord() { } ActiveRecord.prototype = { save: function() { alert(this.tableName ); }, constructor: ActiveRecord }; var activeRecordStatics = { create: function(obj) { return new this(obj); } }; ActiveRecord.create = function( tableName, props, statics ) { function ActiveRecordC( obj ) { this.tableName = tableName; if( props ) { for( var prop in props ) { this[prop] = props[prop]; } } if( obj ) { for( var prop in obj ) { this[prop] = obj[prop]; } } }; ActiveRecordC.prototype = Object.create(ActiveRecord.prototype); for( var key in activeRecordStatics ) { ActiveRecordC[key] = activeRecordStatics[key]; } if( statics ) { for( var key in statics ) { ActiveRecordC[key] = statics[key]; } } return ActiveRecordC; };