Basics

Challenges

Classes

Cookies

Debugging

Events

External Files

Flow Control

Forms

Functions

Html Elements

Installation

Interfaces

Keywords

Modules

Namespaces

Operators

Reference Files

String

Types

TypeScript - Fields


class Spaceship
{
    // fields
    private _designationCode: string;
    private _shipName: string;
    private _numberOfWarpNacelles: number;
    private _numberOfPassengers: number;
    private _numberOfCrew: number;

    private _secretSecurityCode: string = "alpha111"; //never should be shown or changed.
}

 

Whenever you want to refer to a class member that belongs to the class you're in you need to prefix the reference to the member with this followed by a period. this.MyMethod()