Factory Functions & Singleton Pattern

What advantages does this implementation offer?
const createUser = ({ name, email, role = 'user' }) => ({
  name,
  email,
  role,
  createdAt: new Date(),
  id: Math.random().toString(36).substr(2, 9)
});
Next Question (5/32)