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: 
Assuming the OP wants to get the hexadecimal string value of the ObjectId, using Mongo 2.2 or above, the `valueOf()` method returns the representation of the object as a hexadecimal string. This is also achieved with the `str` property.

The link on anubiskong's post gives all the details, the danger here is to use a technique which has changed from older versions e.g. `toString()`.
In Mongoose, you can use toString() method on ObjectId to get a 24-character hexadecimal string.

[Mongoose documentation](https://mongoosejs.com/docs/5.x/docs/schematypes.html#objectids)