ObjectId.valueOf()

On this page本页内容

ObjectId.valueOf()

Returns the value of the ObjectId() as a lowercase hexadecimal string. 以小写十六进制字符串形式返回ObjectId()的值。This value is the str attribute of the ObjectId() object.该值是ObjectId()对象的str属性。

Example示例

The following example calls the valueOf() method on an ObjectId():以下示例调用ObjectId()上的valueOf()方法:

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()
←  ObjectId.toString()UUID() →