如何在 Google Earth Engine 中将值从服务器复制到客户端?

How can I copy a value from server to client in Google Earth Engine?

在Google Earth Engine 上,假设我在服务器端有一个数字。如何在客户端将其作为整数获取?

var x = ee.Number(42)
typeof(x)  //  yields "object", i.e. server side

var y = ??? // what function of x will get me a local 42 in y? 

这似乎可行,尽管 documentation 不推荐:

var x = ee.Number(42)  // server side variable

var z = x.getInfo()  // local string

var y = parseInt(z)