Skip to content


 Zabbix
 Grafana
 Prometheus
 Threejs and TypeScript
 SocketIO and TypeScript
 Blender Topological Earth
 Sweet Home 3D
 Design Patterns Python
 Design Patterns TypeScript
   
 Course Coupon Codes
Three.js and TypeScript
Kindle Edition
$9.99 $14.99 Paperback 
$29.99 $34.99




Design Patterns in TypeScript
Kindle Edition
$9.99 $14.99 Paperback
$19.99 $24.99




Design Patterns in Python
Kindle Edition
$9.99 $14.99 Paperback
$19.99 $24.99




Classes

Video Lecture

TypeScript Classes TypeScript Classes Classes

Description

A Class is essentially a blueprint of what an object is supposed to look like when implemented. A Class can have initialized properties and methods to help create and modify the objects.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
class Grault {
    private garply: string

    constructor(quux: Quux, waldo: number[]) {
        this.garply = quux.quuz + ' ' + quux.corge + ' ' + waldo
    }

    public getGarply() {
        return this.garply
    }
}

interface Quux {
    quuz: string
    corge: number
}

let baz = { quuz: 'ABC', corge: 123 }

let fred: Grault = new Grault(baz, [1, 2, 3])

console.log(fred.getGarply())

Try it,

tsc foo.ts
node foo.js