ee.String.getInfo

Retrieves the value of this object from the server.

If no callback function is provided, the request is made synchronously. If a callback is provided, the request is made asynchronously.

The asynchronous mode is preferred because the synchronous mode stops all other code (for example, the EE Code Editor UI) while waiting for the server. To make an asynchronous request, evaluate() is preferred over getInfo().

Returns the computed value of this object.

UsageReturns
String.getInfo(callback)Object
ArgumentTypeDetails
this: computedobjectComputedObject

The ComputedObject instance.

callbackFunction, optional

An optional callback. If not supplied, the call is made synchronously.

Examples

Code Editor (JavaScript)

// After getInfo(), the instance is a local JavaScript string.
// Regular JavaScript string manipulations are then available.
//
// Note: getInfo() fetches results from Earth Engine immediately, and may freeze
// the browser or lead to poor performance.  Use evaluate() to avoid this.

print(ee.String('abc').getInfo().charAt(1));  // b
print(ee.String('abc').getInfo()[2]);         // c

// Using + with ee.String has unexpected results
print(ee.String('abc') + 'def');  // ee.String("abc")def

// Fetch string using getInfo
print(ee.String('abc').getInfo() + 'def');  // abcdef

// Improved solution: cat is available on ee.String
print(ee.String('abc').cat('def'));  // abcdef