JSUtil - type_of(Object value)

Determines the type of the specified object.

Table 1. Parameters
Name Type Description
value Object The object to check
Table 2. Returns
Type Description
String The type of the specified object.
  • 'null' if the given value is null or undefined
  • 'string' if the given value is a primitive string or a String wrapper instance
  • 'number' if the given value is a primitive number or a Number wrapper instance
  • 'boolean' if the given value is a primitive boolean or a Boolean wrapper instance
  • 'function' if the given value is a function
  • 'object' otherwise

var a = ["a","b","c"];
var b = 10;
var c = new GlideRecord("incident");
var d = true;
var e;
 
gs.print("JSUtil.type_of(a) = " + JSUtil.type_of(a));
gs.print("JSUtil.type_of(b) = " + JSUtil.type_of(b));
gs.print("JSUtil.type_of(c) = " + JSUtil.type_of(c));
gs.print("JSUtil.type_of(d) = " + JSUtil.type_of(d));
gs.print("JSUtil.type_of(e) = " + JSUtil.type_of(e));
Output:
JSUtil.type_of(a) = object
JSUtil.type_of(b) = number
JSUtil.type_of(c) = object
JSUtil.type_of(d) = boolean
JSUtil.type_of(e) = null