November 2018
Beginner
502 pages
10h 22m
English
So far, all our class properties and methods have automatically had the public access modifier. This means they are available to interact with class instances and child classes. We can explicitly set the public keyword on our class properties and methods immediately before the property or method name:
class OrderDetail { public product: Product; public quantity: number; public getTotal(discount: number): number { const priceWithoutDiscount = this.product.unitPrice * this.quantity; const discountAmount = priceWithoutDiscount * discount; return priceWithoutDiscount - discountAmount; }}
As you might have guessed, there is another access modifier, called private, which allows the member to only be available to interact with inside ...
Read now
Unlock full access