Answer the question
In order to leave comments, you need to log in
How to find out the name of a "class" in JS when passing it to a function?
There is a "class":
Class = function( )
{
// ***
};
Class.prototype.func = function( layer )
{
// ***
};
boot.inherit = function( Child, Parent )
{
// Наследуемся
};
boot.inherit( newClass, Class );
Answer the question
In order to leave comments, you need to log in
You are using an anonymous function, so no way.
If you have a named function, it has a name property . It is not supported by IE, if you need its support - you can tear out the name from the source of the function.
function Class(){}
Class.name // => 'Class'
function getName(it){
var match = /^\s*function\s+(\b\w+\b)/.exec(it);
if(match)return match[1];
}
getName(Class) // => 'Class''
function Class(){}
Class.displayName = 'Class';
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question