ee.Number.firstNonZero

Selects the first value if it is non-zero, and the second value otherwise.

UsageReturns
Number.firstNonZero(right)Number
ArgumentTypeDetails
this: leftNumber

The left-hand value.

rightNumber

The right-hand value.

Examples

Code Editor (JavaScript)

print('First non-zero: 0, 5', ee.Number(0).firstNonZero(ee.Number(5)));  // 5
print('First non-zero: 5, 0', ee.Number(5).firstNonZero(ee.Number(0)));  // 5