Classes

ES6 Classes

class Customer {

    constructor(firstName, lastName) {
        this.firstName = firstName;
        this.lastName = lastName;
    }
    
    getName() {
        return this.firstName;
    }

}

Visibility

Meanwhile class fieldsarrow-up-right get supported, visibility rules are just based on a common naming convention where properties and methods get prefixed with the underscore character _ if they are private.

class Customer {

    constructor(firstName, lastName) {
        this.firstName = firstName;
        this.lastName = lastName;
        this.email = null;
        this._isBadPayer = this._tellIfBadPayer();
    }
    
    getName() {
        return this.firstName;
    }
    
    _tellIfBadPayer() {
        return this.firstName === 'foo';
    }

}

Properties

triangle-exclamation

Inheritance

This is inheritance:

circle-exclamation

Best practices

circle-check

Last updated