Tobie, thanks for answer it is helpful but still what I am looking for
is practical advice how do you handle it in Prototype.


Just to clarify:

//this is what I would do without using Prototype

function PureClass(){};
var wow = new PureClass();
wow.constructor;  // and I would get PureClass


// in Prototype the same

var PureClassPrototype = Class.create();
var wow_prototype = new PureClassPrototype();
wow_prototype.constructor; // here I get not very helpfull klass() -
ok it is helpfull and much better than nothing :)
wow_prototype.constructor == PureClassPrototype;  // true

So I am maybe wrong but in JS I get what I want, but in Prototype my
guess is that there is some other way[i have few ideas how to go
around that but I am quite sure It is already solved]..

Or if I am going in very bad direction and what I am trying is
useless,stupid etc ..  please let me know.. :)



Same is for e.g with Class.subclasses , I got Array of [ klass(), klass
() ] and than all I can do is '==' against Something, what I am
looking for is to have in that case array of [Something,
SomethingElse ]

Thanks

dzw!


On Mar 9, 1:08 am, Tobie Langel <[email protected]> wrote:
> 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!" <[email protected]> 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 [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/prototype-scriptaculous?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to