Summary: prototypes as classes
mike.shaver at gmail.com
Tue Jun 28 16:05:18 PDT 2011
On Tue, Jun 28, 2011 at 3:34 PM, Bob Nystrom <rnystrom at google.com> wrote:
> I like the simplicity of this, but I'm not crazy about how it merges two
> distinct objects into one. TodayJS (and most class-based languages) let you
> distinguish two things:
> 1. A set of properties relevant to the class itself.
> 2. A set of properties shared by each instance of the class.
> In a class-based language, #1 up there is "static" methods and fields. So
> when you do something like this in Java:
> The "parseInt" method isn't a method that you can call on an integer, it's a
> method you call on the Integer class itself.
Actually, in Java, you can (or could, when last Java and I spoke) call
class methods on instances:
Integer boxed = new Integer(5);
That doesn't work well in JS, because obviously there's no prevention
of name collisions.
More information about the es-discuss