OO on js
575 ワード
var DomesticChinaDeal = function(){};
DomesticChinaDeal.prototype = {
test: function() {
alert("Hello World");
}
};
DomesticChinaDeal.prototype.constructor = DomesticChinaDeal;
var Factory = function(){};
Factory.prototype = {
getDeal : function() {
return new DomesticChinaDeal();
}
};
Factory.prototype.constructor = Factory;
var deal = new Factory().getDeal();
deal.test();