ee.Number.firstNonZero

Stay organized with collections Save and categorize content based on your preferences.
Selects the first value if it is non-zero, and the second value otherwise.

UsageReturns
Number.firstNonZero(right)Number
ArgumentTypeDetails
this: leftNumberThe left-hand value.
rightNumberThe 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