Aktion “Stoppt die Vorratsdatenspeicherung”

Willst du auch bei der Aktion teilnehmen? Hier findest du alle relevanten Infos und Materialien:
Thursday, 14. June 2007 - 21:32

JavaScript: get_class

Dieser Beitrag ist auch in deutsch verfügbar (empfohlen).


/**
 * Returns the name of the class of an object
 *
 * NOTE: This function doesn't work with 'native code', only with user generated classes.
 *
 * based on http://magnetiq.com/2006/07/10/finding-out-class-names-of-javascript-objects/
 *
 * @param object The object
 * @returns mixed Returns the name of the class of which object is an instance. Returns FALSE if object is not an object.
 */
function get_class(obj)
{
	if(obj && obj.constructor && obj.constructor.toString)
	{
		var arr = obj.constructor.toString().match(/function\s*(\w+)/);
		return (arr && (arr.length==2?arr[1]:undefined));
	}
	else
	{
		return undefined;
	}
}
Filed under: Webdev
Technorati Tags:

Embassies

There are no comments.


Comment entry

Advice:
Commenting isn't available anymore.

Trackback(s)

What's trackback?

A trackback is a kind of a source link. If i was finding an interesting entry in another blog, that i am commenting in my own blog, i am linking to the original message via the trackback. Has someone commented one of my entries in his/her weblog, you can find this link here under trackbacks, too. More informations about trackback are in the Wikipedia for example.

Trackback URL: /trackback/javascript-getclass/

Trackbacks aren't available anymore.

There are no trackbacks for this entry.

Sidebar

Recent acoustic enchantment

Clare Burson - Love Me In The Morning

Random Thought

I code, therefore i am.

Change the emotion

Firefox Add to Technorati Favorites