# Collection Object

> Provides methods for accessing collections.

- **Product:** TX Text Control .NET Server
- **Section:** Reference
- **Kind:** Object
- **Introduced:** 28.0
- **Path:** TX Text Control .NET Server > Reference > JavaScript API > Collection Object
- **560 words**
- **Web URL:** https://docs.textcontrol.com/tx-text-control-dotnet-server/reference/javascript/collection/
- **LLMs URL:** https://docs.textcontrol.com/tx-text-control-dotnet-server/reference/javascript/collection/llms.txt
- **LLMs-Full URL:** https://docs.textcontrol.com/tx-text-control-dotnet-server/reference/javascript/collection/llms-full.txt

---

### Description

Provides methods for accessing collections.

### Syntax

```javascript
Collection
```

### Examples

The following example shows how to retrieve all application fields from the document's main text and do something with them afterwards:

```javascript
let fields = [];
TXTextControl.applicationFields.forEach((field, i, n) => {
   fields.push(field);
   if (i == (n - 1)) {
      console.log(`${fields.length} application fields retrieved!`);
      // Do something meaningful with the retrieved fields here...
   }
});


Possible console output after calling this code:

> 17 application fields retrieved!
```

The following example demonstrates `Collection` in a practical document-editing workflow. It provides methods for accessing collections.

```javascript
function onTxError(error) {
    console.error("TX Text Control error:", error.msg);
    error.handled = true;
}

function inspectCollection(s) {
    s.getCount(
        function(result) {
            console.log("get count result:", result);
        },
        onTxError
    );
}
```

---

## In This Section

- [Javascript: Collection.elementAt Method](https://docs.textcontrol.com/tx-text-control-dotnet-server/reference/javascript/collection/elementat-method/llms-full.txt): Returns the element at a specified index in the collection.
- [Javascript: Collection.forEach Method](https://docs.textcontrol.com/tx-text-control-dotnet-server/reference/javascript/collection/foreach-method/llms-full.txt): Executes a callback function for each element.
- [Javascript: Collection.getCount Method](https://docs.textcontrol.com/tx-text-control-dotnet-server/reference/javascript/collection/getcount-method/llms-full.txt): Gets the number of elements contained in the collection.

---

## Nearby

- **Previous:** [Javascript: ClipboardTransferStartEventArgs.id Property](https://docs.textcontrol.com/tx-text-control-dotnet-server/reference/javascript/clipboardtransferstarteventargs/id-property/llms-full.txt)
- **Next:** [Javascript: Collection.elementAt Method](https://docs.textcontrol.com/tx-text-control-dotnet-server/reference/javascript/collection/elementat-method/llms-full.txt)
