Un generatore pseudo-ObjectId in JavaScript può essere utile quando serve un identificativo plausibile lato client.
const ObjectId = (m = Math, d = Date, h = 16, s = x => m.floor(x).toString(h)) =>
s(d.now() / 1000) +
' '.repeat(h).replace(/./g, () => s(m.random() * h));
La struttura imita quella reale: timestamp in secondi più componente casuale, tutto in esadecimale. Non sostituisce un vero ObjectId BSON, ma è comodo per generare id unici e verosimili.