[JS] – How to implement classes in JavaScript ?

Classes are the programmatic structures that define a business model.

Example :

We will define here the Client class in JavaScript.

class Client {

    constructor(name, city, email) {
        this.name = name;
        this.city = city;
        this.email = email;
        this._dt_created = new Date();   

    get name() {
        return this.name ;

    get city() {
        return this.city; // novidade aqui! retorna uma nova Data

    get email() {
        return this.email;

    get dt_created(){
        return this._dt_created;

How to create a object from this class ?

        var newClient = new Client("name", "city", "email");


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s