If you liked Reporting file, function and line number in Apps Script, you’ll probably also like this one. This shows how to get some properties about an object in apps script, and can be useful for debugging.

Here’s how

This function is available in the Useful stuff library, or you can copy from here. It will return information about JavaScript primitives or objects

Returned values for primitives

Not super useful, but just to complete the picture.


Of course Arrays are just a kind of object, and typeof [] will return ‘object’. You can see here that the name property returned will be ‘Array’ – so an Array is defined as type:object, name:Array

Custom Objects

The main usage of this is to help with debugging your custom objects. An anonymous objects is detected as type:object, name:Object


When you create your own ‘classes’, then the constructor is a function. A constructor is detected like any other function – type:function , name:Function

Object instance

Testing an instance of a ‘class’ will give you something more interesting. The name property will be the name of the constructor function used to create the object, the nargs property will show how many arguments that function expects to receive, and the value will be the stringified properties of the instance.

Apps Script Services

Unfortunately, there’s not a lot of info on Apps Script services – they are detected as an Anonymous object.

For more like this see Google Apps Scripts Snippets

For help and more information join our forum, follow the blog orfollow me on Twitter