ObjectId.toString()
ObjectId.
toString
()- Returns the string representation of the
ObjectId()
. Thisstring value has the format ofObjectId(…)
.
Example
The following example calls the toString()
methodon an ObjectId()
instance in the mongo
shell:
- ObjectId("507c7f79bcf86cd7994f6c0e").toString()
This will return the following string:
- ObjectId("507c7f79bcf86cd7994f6c0e")
You can confirm the type of this object using the followingoperation:
- typeof ObjectId("507c7f79bcf86cd7994f6c0e").toString()