Take the 2-minute tour ×

I'd like to know if there is a way to determine if a variable contains a MooTools Class instance.

Here's the example below in jsFiddle: http://jsfiddle.net/kGnaa/

var a = new Class();
var aInstance = new a();
document.write('#1 instanceOf(aInstance,a) = ' + instanceOf(aInstance,a) + '<br>') // aInstance is instance of a. Returns true.
document.write('#2 instanceOf(aInstance,Class) = ' + instanceOf(aInstance,Class) + '<br>') // aInstance isn't instance of Class, so returns false.

Is there a way to make #2 happen?

share|improve this question
add comment

1 Answer

up vote 1 down vote accepted

I think I got it.

var Foo = new Class({});
var FooInstance = new Foo();
alert(typeOf(FooInstance.$constructor)); // alerts 'class'
share|improve this answer
add comment

Your Answer


