JSUtil - notNil(Object item)

Checks if item is null, undefined, or evaluates to the empty string.

Table 1. Parameters
Name Type Description
item Object The object to check
Table 2. Returns
Type Description
Boolean True if the item exists and is not empty.

var x = "the quick brown fox";
var y = "";
var z;
 
gs.print("x = '" + x + "', JSUtil.notNil(x) = " + JSUtil.notNil(x));
gs.print("y = '" + y + "', JSUtil.notNil(y) = " + JSUtil.notNil(y));
gs.print("z = '" + z + "', JSUtil.notNil(z) = " + JSUtil.notNil(z));
Output:
x = 'the quick brown fox', JSUtil.notNil(x) = true
y = '', JSUtil.notNil(y) = false
z = 'undefined', JSUtil.notNil(z) = false