I believe the only difference between the two is that in the first you're 
creating a prototyped class, where in the second you're creating a static 
namespace containing functions.

The only extra overhead you'll see is from the call to Class.create().

Cheers,
Joe

-----Original Message-----
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Behalf Of Brian Feliciano
Sent: Thursday, July 20, 2006 12:28 PM
To: rails-spinoffs@lists.rubyonrails.org
Subject: Re: [Rails-spinoffs] Javascript Namespacing Question


wow! this list is hot! :D 
thanks for the instant replies! i'm starting to love this list. :D

my last question ( of this thread :D )
is there a difference between:

var ObjectName = Class.create();
ObjectName.prototype = {
  initialize: function () {},
  doThis: function () {}
}
var obj = new ObjectName();
obj.doThis();

and 

var ObjectName = {
  initialize: function () {},
  doThis: function () {}
}
ObjectName.doThis();

i know their difference coding-wise, but im a bit concerned about speed and 
performance and efficiency. (as you may have already noticed, im a bit paranoid 
about performance/speed)




On 7/21/06, Ryan Gahl <[EMAIL PROTECTED]> wrote:
Nope, that should work out just fine, but I would just call that "namespacing" 
(YUI didn't invent that concept)... :-)
_______________________________________________
Rails-spinoffs mailing list
Rails-spinoffs@lists.rubyonrails.org
http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs

Reply via email to