Question: I want to convert ObjectID (Mongodb) to String in JavaScript.
When I get a Object form MongoDB. it like as a object has: timestamp, second, inc, machine.
I can't convert to string.

Answer: 
You can use [**`$toString`**](https://docs.mongodb.com/manual/reference/operator/aggregation/toString/) aggregation introduced in mongodb version **4.0** which converts the ObjectId to string

```
db.collection.aggregate([
  { "$project": {
    "_id": { "$toString": "$your_objectId_field" }
  }}
])

```
You could use `String`

```
String(a['_id'])

```