Classes
Video Lecture
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.
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