Create class in JavaScript

I'm newbie to JavaScript , I know there is a way to create class in JS even if JS not support it like this :

function User()
{
    this.username = '';
    this.password = '';
    this.setInfo = function(username, password){
        this.username = username;
        this.password = password;
    };

    this.checkLogin = function(){
        return (this.username === 'admin' && this.password === '@123');
    };
    return this;
}

and create an object of class User : var user = new User(); By doing like this I can code with objects like Java, but should I use it popularly in real JS project ?

2 answers