- Reference >
mongoShell Methods >- Object Constructors and Methods >
- ObjectId.valueOf()
ObjectId.valueOf()¶
-
ObjectId.valueOf()¶ Returns: The value of the ObjectId() object as a lowercase hexadecimal string. This value is the strattribute of theObjectId()object.Changed in version 2.2: In previous versions
ObjectId.valueOf()returns theObjectId()object.In the following example, call the
valueOf()method on an ObjectId (e.g.ObjectId("507c7f79bcf86cd7994f6c0e")):This will return the following string:
You can confirm the type of this object using the following operation: