class User { constructor(name,auth){ this.name = name; this.auth = auth; } } class UserFactory{ static createUser(name,auth){ if(auth === 'admin') { return new User(name,1) } if(auth === 'user'){ return new User(name,2) } } } const admin = UserFactory.createUser("zhangsan",'admin') const user = UserFactory.createUser("lisi","user"); console.log(admin); console.log(user);