With the first method you are creating one static object, with the second you have a method of creating as many instances of that object as you need.
You pick the one that best suits your need. On 21/05/06, Maninder, Singh <[EMAIL PROTECTED]> wrote:
Hi, I have a basic question about Class.create() Vs creating objects. I would like to know the pros of one over the other (which one I don't know). Problem Description: I would like to write an object "Browser" that has methods like getName, getVersion... I could do it any of the following ways - var Browser = { this.getName: function() { }, this.getVersion: function() { } }; Or I could do - var Browser = Class.create(); Browser.prototype = { initialize: function() { }, getName: function() { }, getVersion: function() { } } In the first case when I created an object, I can use it as Browser.getName() whereas in the second case when I used Class.create(), I need to first do new Browser(); Browser.getName(); Just want to know if it's a good idea or a bad one to create classes and not objects? Could there be memory problems with too many classes? Thanks, Mandy. _______________________________________________ Rails-spinoffs mailing list Rails-spinoffs@lists.rubyonrails.org http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs
-- Andrew Tetlaw htp://tetlaw.id.au
_______________________________________________ Rails-spinoffs mailing list Rails-spinoffs@lists.rubyonrails.org http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs