JSUtil - instance_of(Object item, String class)

Checks to see if the specified object is a member of the specified class.

For JavaScript objects, this method behaves exactly like the JavaScript operator "instanceof", but also supports Java objects.

Table 1. Parameters
Name Type Description
item Object The object to check
class String The class to check
Table 2. Returns
Type Description
Boolean True if the specified object is a member of the specified class.

var a = ['a','b','c'];
var b = 10;
var c = new GlideRecord("incident");
 
gs.print("JSUtil.instance_of(a,'Array') = " + JSUtil.instance_of(a,Array));
gs.print("JSUtil.instance_of(a,'String') = " + JSUtil.instance_of(a,String));
 
gs.print("JSUtil.instance_of(b,'String') = " + JSUtil.instance_of(b,String));
 
gs.print("JSUtil.instance_of(c,'GlideRecord') = " + JSUtil.instance_of(c,GlideRecord));
Output:
JSUtil.instance_of(a,'Array') = true
JSUtil.instance_of(a,'String') = false
JSUtil.instance_of(b,'String') = false
JSUtil.instance_of(c,'GlideRecord') = true