01 Typescript Classes Overview
01 Typescript Classes Overview
Customer Class
class Customer {
// properties
// constructors
class Customer {
// properties
// constructors
// constructors
class Customer {
// properties
firstName: string;
lastName: string;
class Customer {
// properties
firstName: string;
lastName: string;
class Customer {
Properties are
// properties
firstName: string; public by default
lastName: string;
class Customer {
Properties are
// properties
firstName: string; public by default
lastName: string;
}
We'll cover access
modifiers shortly
// properties
firstName: string;
lastName: string;
myCustomer.firstName = "Martin";
myCustomer.lastName = "Dixon";
console.log(myCustomer.firstName);
console.log(myCustomer.lastName);
// properties
firstName: string;
lastName: string;
myCustomer.firstName = "Martin";
myCustomer.lastName = "Dixon";
console.log(myCustomer.firstName);
console.log(myCustomer.lastName);
myCustomer.firstName = "Martin";
myCustomer.lastName = "Dixon";
console.log(myCustomer.firstName);
console.log(myCustomer.lastName);
myCustomer.firstName = "Martin";
myCustomer.lastName = "Dixon";
console.log(myCustomer.firstName);
console.log(myCustomer.lastName);
myCustomer.firstName = "Martin";
myCustomer.lastName = "Dixon";
console.log(myCustomer.firstName);
console.log(myCustomer.lastName);
class Customer {
firstName: string;
lastName: string;
class Customer {
firstName: string;
lastName: string;
class Customer {
"constructor"
keyword
firstName: string;
lastName: string;
class Customer {
"constructor"
keyword
firstName: string;
lastName: string;
class Customer {
firstName: string;
lastName: string;
console.log(myCustomer.firstName);
console.log(myCustomer.lastName);
class Customer {
firstName: string;
lastName: string;
console.log(myCustomer.firstName);
console.log(myCustomer.lastName);
class Customer {
console.log(myCustomer.firstName);
console.log(myCustomer.lastName);
class Customer {
Modifier Definition
Modifier Definition
Modifier Definition
Modifier Definition
class Customer {
myCustomer.firstName = "Susan";
myCustomer.lastName = "Public";
console.log(myCustomer.firstName);
console.log(myCustomer.lastName);
class Customer {
console.log(myCustomer.firstName);
console.log(myCustomer.lastName);
class Customer {
console.log(myCustomer.firstName);
console.log(myCustomer.lastName);
16 myCustomer.firstName = "Susan";
…
…
…
16 myCustomer.firstName = "Susan";
…
…
…
16 myCustomer.firstName = "Susan";
…
…
…
16 myCustomer.firstName = "Susan";
…
…
…
C:\> dir
Customer.js Customer.ts
C:\> dir
Customer.js Customer.ts
C:\> dir
Customer.js Customer.ts
What???
C:\> dir
Customer.js Customer.ts
What???
C:\> dir
Customer.ts
C:\> dir
Customer.ts
C:\> dir
Customer.ts
C:\> dir
Yaaay!
Customer.ts
The .js file was NOT generated!