Javascript: Collection.elementAt Method
Description
Returns the element at a specified index in the collection.
Syntax
<void> Collection.elementAt(<number> index, <RequestObjectCallback> callback, [<ErrorCallback> errorCallback])Parameters
| Parameter | Description |
|---|---|
| index | The zero-based index of the element to retrieve. |
| callback | Receives the element as a parameter. |
| errorCallback | Optional. Is called when the operation failed with an error. |
Examples
The following example demonstrates Collection.elementAt in a practical document-editing workflow. It returns the element at a specified index in the collection.
function onTxError(error) {
console.error("TX Text Control error:", error.msg);
error.handled = true;
}
function elementAt(s) {
s.elementAt(
0,
function(obj) {
if (!obj) {
console.warn("No object was returned.");
return;
}
console.log("element at result:", obj);
},
onTxError
);
}