-1
const myObjectId = ObjectId("507c7f79bcf86cd7994f6c0e")
const myObjectIdString = myObjectId.toString()

myObjectId has a size of 12 bytes. But what about the size of myObjectIdString?

  • 1
    Surely writing `console.log(Buffer.from(myObjectIdString).length)` is way quicker than posting a Stackoverflow question. And as an additional bonus you get the answer instantly. – Alex Blex Jan 15 '23 at 18:30
  • Does this answer your question? [How many bytes in a JavaScript string?](https://stackoverflow.com/questions/2219526/how-many-bytes-in-a-javascript-string) – jsejcksn Jan 16 '23 at 02:59

1 Answers1

1

This ObjectId is a 24-character hexadecimal string representation and when it's represented as a string it's 24 bytes.

abdemirza
  • 629
  • 4
  • 16