Navigation

ObjectId.toString()

On this page

ObjectId.toString()

Returns the string representation of the ObjectId(). This string value has the format of ObjectId(...).

Example

The following example calls the toString() method on an ObjectId():

ObjectId("507c7f79bcf86cd7994f6c0e").toString()

This will return the following string:

ObjectId("507c7f79bcf86cd7994f6c0e")

You can confirm the type of this object using the following operation:

typeof ObjectId("507c7f79bcf86cd7994f6c0e").toString()