Hi,

JavaScript, as a language doesn't have the self-reflexiveness you are
looking for.

There are different hacks to find this kind of information, but imho
they go against the dynamic and prototypical nature of the language.

When you do:

    var Foo = Class.create({});

what you are actually doing is creating a constructor (a function
declaration contained in the closure created by Class.create), which
you then assign to the "Foo" variable. (In prototype, that constructor
happens to be called "klass", but it could be called anything else,
that wouldn't change anything).

It would now be very well possible to do:

    var Bar = Foo;

and use:

    new Bar();

to create a new "Foo" object.

If the classes you create are in the global scope, you can always
iterate over the global object (window, or this) to find the name of
the variable that points to your constructor object. But apart from
debugging purposes, there is little use for that.

Hope this clarifies your issue.

Best,

Tobie


On Mar 8, 12:19 pm, "dzw!" <bartoszw...@googlemail.com> wrote:
> Houston, new Prototype user has a problem:
>
> var SimpleClass = Class.create({})
> var xxx = new SimpleClass();
>
> xxx.constructor == SimpleClass // i got true
>
> xxx.constructor // i got klass()
>
> So what I am looking  is: how to get the constructor name? the same is
> with Prototype's superclass and subclasses.. I tried to google it but
> with no success.
>
> Any hint? What is about that "klass()" thing?
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Prototype & script.aculo.us" group.
To post to this group, send email to prototype-scriptaculous@googlegroups.com
To unsubscribe from this group, send email to 
prototype-scriptaculous+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/prototype-scriptaculous?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to