Silly me. I forgot about "Native":
=============
Native.implement({
is:function(type){
return typeOf(this)==type;
}
});
=============
http://jsfiddle.net/jiggliemon/24TXR/2/
On Jun 6, 10:35 am, jiggliemon <[email protected]> wrote:
> @arian:
> There's jut a few things I see.
> 1. You're still using the "is" word; I have no idea if this is going
> to piss off IE. I'll test it Monday.
> 2. There's no way to so {im:'object'}.is('object');
>
> So you would have to extend Object, and when you do that, there's no
> reason to extend all the other Natives, cause it's the parent Object.
> so the following should take care of it all (if we're using is):
>
> Object.prototype.is = function(type){
> return typeOf(this)==type;
>
> }
>
> On Jun 6, 1:54 am, Arian <[email protected]> wrote:
>
>
>
> > Of course it can be much shorter than 20 lines ;)
> > :http://jsfiddle.net/BDEWf/6/
>
> > On Jun 5, 10:55 pm, jiggliemon <[email protected]> wrote:
>
> > > Oskar pointed out that "is" is a reserved word in Javascript so it
> > > could cause problems in IE1+
> > > Not to mention the Taboo of extending Object.
>
> > > It just seems a little cumbersome having to write 20-lines and extend
> > > all the Native objects to essentially get the same functionality as
> > > the 3-liner object extender.
>
> > >http://jsfiddle.net/jiggliemon/24TXR/
>
> > > On Jun 5, 7:24 am, Ryan Florence <[email protected]> wrote:
>
> > > > I've done this a few times, I certain like looking at:
>
> > > > if (arg.isNumber())
>
> > > > than looking at
>
> > > > if ($type(arg) == 'number')
>
> > > > Yours is pretty creative.
>
> > > > On Jun 4, 2010, at 11:29 PM, jiggliemon wrote:
>
> > > > > What about having a simple "is" method on all the main types?
> > > > >http://jsfiddle.net/jiggliemon/BDEWf/2/
>
> > > > > -Chase