ee.Number.and

  • The Number.and() method returns 1 if and only if both input numbers are non-zero.

  • The method takes two number arguments, left and right.

  • Examples in both JavaScript and Python demonstrate the method's behavior with non-zero and zero inputs.

Returns 1 if and only if both values are non-zero.

UsageReturns
Number.and(right)Number
ArgumentTypeDetails
this: leftNumberThe left-hand value.
rightNumberThe right-hand value.

Examples

Code Editor (JavaScript)

print('Both 5 and 10 are not 0?', ee.Number(5).and(ee.Number(10)));  // 1
print('Both 5 and 0 are not 0?', ee.Number(5).and(ee.Number(0)));  // 0

Python setup

See the Python Environment page for information on the Python API and using geemap for interactive development.

import ee
import geemap.core as geemap

Colab (Python)

# 1
print('Both 5 and 10 are not 0?', ee.Number(5).And(ee.Number(10)).getInfo())
# 0
print('Both 5 and 0 are not 0?', ee.Number(5).And(ee.Number(0)).getInfo())