Docs Home → Develop Applications → MongoDB Manual
ObjectId.valueOf()![](/docs/v5.2/assets/link.svg)
On this page
This version of the documentation is archived and no longer supported. View the current documentation to learn how to upgrade your version of MongoDB server.
ObjectId.valueOf()
Returns the value of the
ObjectId()
as a lowercase hexadecimal string. This value is thestr
attribute of theObjectId()
object.
Example![](/docs/v5.2/assets/link.svg)
The following example calls the valueOf()
method on an ObjectId()
:
ObjectId("507c7f79bcf86cd7994f6c0e").valueOf()
This will return the following string:
507c7f79bcf86cd7994f6c0e
You can confirm the type of this object using the following operation:
typeof ObjectId("507c7f79bcf86cd7994f6c0e").valueOf()