groups

name language licence
Find all subviews with matching resize mask Objective-C Other
Random integer between two specific values Objective-C Other
Custom Two-View Predicate Editor keypath=BOOL Template Objective-C Other
Examine View/Subview Bindings Objective-C Other
Get Class Name for Object Javascript Other

< 1 2 3 4 >



language: Javascript
licence: Other

Get Class Name for Object

options: view full snippetsend to code collector
/*
   Get the class of a javascript object. Yes, Javascript doesn't really have classes but
   sometimes its nice to know who you're talking to other than "object"
*/
<script language = "Javascript">

function objectClass( obj )
{
	var className = undefined;
	
	if( obj && obj.constructor && obj.constructor.toString() )
	{
		var arr = obj.constructor.toString().match(/function\s*(\w+)/);  
        if( arr && arr.length == 2 )
            className = arr[1];
	
(Continues...)