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: 
in the [shell](https://docs.mongodb.com/manual/reference/method/ObjectId/)

`ObjectId("507f191e810c19729de860ea").str`

in js [using the native driver for node](http://mongodb.github.io/node-mongodb-native/2.0/api/ObjectID.html)

`objectId.toHexString()`
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()`.