# Javascript: CommentCollection.remove Method

> Removes a comment from the collection.

- **Product:** DS Server
- **Section:** Reference
- **Kind:** Method
- **Introduced:** 30.0
- **Path:** DS Server > Reference > JavaScript API > Javascript: CommentCollection.remove Method
- **453 words**
- **Web URL:** https://docs.textcontrol.com/ds-server/reference/javascript/commentcollection/remove-method/
- **LLMs URL:** https://docs.textcontrol.com/ds-server/reference/javascript/commentcollection/remove-method/llms.txt
- **LLMs-Full URL:** https://docs.textcontrol.com/ds-server/reference/javascript/commentcollection/remove-method/llms-full.txt

---

### Description

Removes a comment from the collection.

### Syntax

```javascript
<void> CommentCollection.remove(<CommentedText> comment, [<RequestBooleanCallback> callback], [<ErrorCallback> errorCallback])
```

### Parameters

| Parameter | Description |
|---|---|
| comment | Specifies the comment to remove. |
| callback | Optional. Receives whether the removal was successful. |
| errorCallback | Optional. Is called when the operation failed with an error. |

### Examples

The following example demonstrates `CommentCollection.remove` in a practical document-editing workflow. It removes a comment from the collection.

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

function remove(comment) {
    TXTextControl.textParts.getMainText(function(mainText) {
        const comments = mainText.comments;
        comments.remove(
            comment,
            function(result) {
                if (result) {
                    console.log("remove is available.");
                } else {
                    console.warn("remove is not available in the current document state.");
                }
            },
            onTxError
        );
    }, onTxError);
}
```

---

## Nearby

- **Previous:** [Javascript: CommentCollection.getPreviousItem Method](https://docs.textcontrol.com/ds-server/reference/javascript/commentcollection/getpreviousitem-method/llms-full.txt)
- **Next:** [CommentedText Object](https://docs.textcontrol.com/ds-server/reference/javascript/commentedtext/llms-full.txt)
