- Reference >
mongoshMethods >- Object Constructors and Methods >
- ObjectId.toString()
ObjectId.toString()¶
On this page
-
ObjectId.toString()¶ Returns the string representation of the
ObjectId(). This string value has the format ofObjectId(...).
Example¶
The following example calls the toString() method
on an ObjectId() instance in mongosh:
This will return the following string:
You can confirm the type of this object using the following operation: