How to randomly generate objectid in node js

I need to randomly generate objectid in node js.Is there is any way to create.

If you mean a MongoDB ObjectID, try this:

var ObjectID = require('mongodb').ObjectID;

var objectId = new ObjectID();

Let me know if this is what you're looking for.

// On top of your script, or whatever
var crypto = require('crypto');

// wherever you want
function randomObjectId() {
    return crypto.createHash('md5').update(Math.random().toString()).digest('hex').substring(0, 24);
}