How do you determine the type of a prototype object? I have a hashmap that was created using $H(). var temp = new $H(); typeof temp: "object" temp.constructor(): [object Object] I know the the $H() is initially created by extending object but is there anyway to figure out if the temp object is of type Hash? Of course, this is aside from evaluating the existence of temp.values(). _______________________________________________ Rails-spinoffs mailing list Rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs
Not as far as I know. I think only built-ins can have a different type value, but I could be wrong. Would be nice if Javascript supported true subclassing, but I don''t believe it does. Greg ________________________________ From: rails-spinoffs-bounces-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org [mailto:rails-spinoffs-bounces-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org] On Behalf Of Casey O''Neill Sent: Wednesday, June 07, 2006 1:54 PM To: rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org Subject: [Rails-spinoffs] Determining the type of an object How do you determine the type of a prototype object? I have a hashmap that was created using $H(). var temp = new $H(); typeof temp: "object" temp.constructor (): [object Object] I know the the $H() is initially created by extending object but is there anyway to figure out if the temp object is of type Hash? Of course, this is aside from evaluating the existence of temp.values (). _______________________________________________ Rails-spinoffs mailing list Rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs
That''s what I was afraid of. Thanks for your input. On 6/7/06, Gregory Hill <Gregory_Hill-l9nu40+TWxQ@public.gmane.org> wrote:> > Not as far as I know. I think only built-ins can have a different type > value, but I could be wrong. > > > > Would be nice if Javascript supported true subclassing, but I don''t > believe it does. > > > > Greg > > > ------------------------------ > > *From:* rails-spinoffs-bounces-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org [mailto: > rails-spinoffs-bounces-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org] *On Behalf Of *Casey O''Neill > *Sent:* Wednesday, June 07, 2006 1:54 PM > *To:* rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > *Subject:* [Rails-spinoffs] Determining the type of an object > > > > How do you determine the type of a prototype object? I have a hashmap that > was created using $H(). > > var temp = new $H(); > > typeof temp: "object" > temp.constructor (): [object Object] > > I know the the $H() is initially created by extending object but is there > anyway to figure out if the temp object is of type Hash? Of course, this is > aside from evaluating the existence of temp.values (). > > _______________________________________________ > Rails-spinoffs mailing list > Rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs > > >_______________________________________________ Rails-spinoffs mailing list Rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs
http://www.webreference.com/js/column79/7.html And IE supports the "instanceof" operator natively. On 6/7/06, Gregory Hill <Gregory_Hill-l9nu40+TWxQ@public.gmane.org> wrote:> > Not as far as I know. I think only built-ins can have a different type > value, but I could be wrong. > > > > Would be nice if Javascript supported true subclassing, but I don''t > believe it does. > > > > Greg > > > ------------------------------ > > *From:* rails-spinoffs-bounces-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org [mailto: > rails-spinoffs-bounces-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org] *On Behalf Of *Casey O''Neill > *Sent:* Wednesday, June 07, 2006 1:54 PM > *To:* rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > *Subject:* [Rails-spinoffs] Determining the type of an object > > > > How do you determine the type of a prototype object? I have a hashmap that > was created using $H(). > > var temp = new $H(); > > typeof temp: "object" > temp.constructor (): [object Object] > > I know the the $H() is initially created by extending object but is there > anyway to figure out if the temp object is of type Hash? Of course, this is > aside from evaluating the existence of temp.values (). > > _______________________________________________ > Rails-spinoffs mailing list > Rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs > > >_______________________________________________ Rails-spinoffs mailing list Rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs
There is the instanceof operator. function MyClass() {} var x = new MyClass(); alert(x instanceof MyClass); As for subclassing see this: http://javascript.crockford.com/inheritance.html On 08/06/06, Gregory Hill <Gregory_Hill-l9nu40+TWxQ@public.gmane.org> wrote:> > > > > Not as far as I know. I think only built-ins can have a different type > value, but I could be wrong. > > > > Would be nice if Javascript supported true subclassing, but I don''t believe > it does. > > > > Greg > > > > > ________________________________ > > > From: rails-spinoffs-bounces-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > [mailto:rails-spinoffs-bounces-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org] On > Behalf Of Casey O''Neill > Sent: Wednesday, June 07, 2006 1:54 PM > To: rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > Subject: [Rails-spinoffs] Determining the type of an object > > > > > How do you determine the type of a prototype object? I have a hashmap that > was created using $H(). > > var temp = new $H(); > > typeof temp: "object" > temp.constructor (): [object Object] > > I know the the $H() is initially created by extending object but is there > anyway to figure out if the temp object is of type Hash? Of course, this is > aside from evaluating the existence of temp.values (). > > _______________________________________________ > Rails-spinoffs mailing list > Rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs > > >-- Andrew Tetlaw htp://tetlaw.id.au
Right... I thought I just said there was an instanceof operator in my post just before yours in this thread. I know it works in IE, not sure about the other browsers. And as for that link about subclassing... Sorry, it''s just that, well, this is the prototype/scriptaculous mailing list, and that link seems to be a few years old and a few dollars short. Prototype.js gives all the facilities mentioned in that article, and quite a bit more. Do you not use protoype? On 6/8/06, Andrew Tetlaw <atetlaw-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > There is the instanceof operator. > > function MyClass() {} > > var x = new MyClass(); > > alert(x instanceof MyClass); > > As for subclassing see this: > http://javascript.crockford.com/inheritance.html > > > On 08/06/06, Gregory Hill <Gregory_Hill-l9nu40+TWxQ@public.gmane.org> wrote: > > > > > > > > > > Not as far as I know. I think only built-ins can have a different type > > value, but I could be wrong. > > > > > > > > Would be nice if Javascript supported true subclassing, but I don''t > believe > > it does. > > > > > > > > Greg > > > > > > > > > > ________________________________ > > > > > > From: rails-spinoffs-bounces-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > > [mailto:rails-spinoffs-bounces-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org] On > > Behalf Of Casey O''Neill > > Sent: Wednesday, June 07, 2006 1:54 PM > > To: rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > > Subject: [Rails-spinoffs] Determining the type of an object > > > > > > > > > > How do you determine the type of a prototype object? I have a hashmap > that > > was created using $H(). > > > > var temp = new $H(); > > > > typeof temp: "object" > > temp.constructor (): [object Object] > > > > I know the the $H() is initially created by extending object but is > there > > anyway to figure out if the temp object is of type Hash? Of course, this > is > > aside from evaluating the existence of temp.values (). > > > > _______________________________________________ > > Rails-spinoffs mailing list > > Rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > > http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs > > > > > > > > > -- > Andrew Tetlaw > htp://tetlaw.id.au > _______________________________________________ > Rails-spinoffs mailing list > Rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs >_______________________________________________ Rails-spinoffs mailing list Rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs
On 09/06/06, Ryan Gahl <ryan.gahl-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Right... I thought I just said there was an instanceof operator in my post > just before yours in this thread. I know it works in IE, not sure about the > other browsers.Sorry, replied to Greg before I read yours. it does work in both IE and Moz, I''ve used it before.> > And as for that link about subclassing... Sorry, it''s just that, well, this > is the prototype/scriptaculous mailing list, and that link seems to be a few > years old and a few dollars short. Prototype.js gives all the facilities > mentioned in that article, and quite a bit more. Do you not use protoype?Again, I was reply to Greg when he said "Would be nice if Javascript supported true subclassing, but I don''t believe it does." And if you''ve never heard of Douglas Crockford, then that''s your problem. Why so shirty? I was only trying to help. -- Andrew Tetlaw htp://tetlaw.id.au
Ok, my bad. Thought you were like unaware of prototype.js or something based on that link. Not trying to be "shirty", was just pointing out that proto does all that stuff, and didn''t know if you knew or not... Not sure what knowing Douglas Crockford or not has to do with it. Oh well, whatever. On 6/9/06, Andrew Tetlaw <atetlaw-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > On 09/06/06, Ryan Gahl <ryan.gahl-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > Right... I thought I just said there was an instanceof operator in my > post > > just before yours in this thread. I know it works in IE, not sure about > the > > other browsers. > > Sorry, replied to Greg before I read yours. it does work in both IE > and Moz, I''ve used it before. > > > > > And as for that link about subclassing... Sorry, it''s just that, well, > this > > is the prototype/scriptaculous mailing list, and that link seems to be a > few > > years old and a few dollars short. Prototype.js gives all the facilities > > mentioned in that article, and quite a bit more. Do you not use > protoype? > > Again, I was reply to Greg when he said "Would be nice if Javascript > supported true subclassing, but I don''t believe it does." > > And if you''ve never heard of Douglas Crockford, then that''s your > problem. Why so shirty? I was only trying to help. > > -- > Andrew Tetlaw > htp://tetlaw.id.au > _______________________________________________ > Rails-spinoffs mailing list > Rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs >_______________________________________________ Rails-spinoffs mailing list Rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs
On 6/9/06, Ryan Gahl <ryan.gahl-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> was just pointing out that proto > does all that stuffNo. Prototype.js actually does far less than the methods described in Douglas'' article, you must have misread it. The current prototype implementation is at the bottom end of what is possible. And as you have noticed, the article is five years old.
Yeah, I gotta learn not to post my thoughts I''m not totally sure about on this list. ''Cause when I do, someone proves me wrong :( Thanks for the info; learn something new every day :) Greg> -----Original Message----- > From: rails-spinoffs-bounces-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org[mailto:rails-spinoffs-> bounces-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org] On Behalf Of Andrew Tetlaw > Sent: Friday, June 09, 2006 5:28 AM > To: rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > Subject: Re: [Rails-spinoffs] Determining the type of an object > > On 09/06/06, Ryan Gahl <ryan.gahl-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > Right... I thought I just said there was an instanceof operator inmy> post > > just before yours in this thread. I know it works in IE, not sureabout> the > > other browsers. > > Sorry, replied to Greg before I read yours. it does work in both IE > and Moz, I''ve used it before. > > > > > And as for that link about subclassing... Sorry, it''s just that,well,> this > > is the prototype/scriptaculous mailing list, and that link seems tobe a> few > > years old and a few dollars short. Prototype.js gives all thefacilities> > mentioned in that article, and quite a bit more. Do you not use > protoype? > > Again, I was reply to Greg when he said "Would be nice if Javascript > supported true subclassing, but I don''t believe it does." > > And if you''ve never heard of Douglas Crockford, then that''s your > problem. Why so shirty? I was only trying to help. > > -- > Andrew Tetlaw > htp://tetlaw.id.au > _______________________________________________ > Rails-spinoffs mailing list > Rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs