classInfo{private name:string;constructor(n:string){this.name = n ;};describe(){console.log(`Your name is ${this.name}`);}}const a =newInfo('joyous');
a.describe();
classPerson{private name:string;publicconstructor(name:string){this.name = name
}publicgetName():string{returnthis.name;}}var p =newPerson("Jane Doe");console.log(p.getName());/*this example is more proper than the previous, though the previous example is syntax-wise correct*/
exportclassIngredient{//This is a shortcut to what is written below constructor(public name:String,public amount:String){}}// On top is the same as below //// export class Ingredient{// public name: String;// public amount: Number;// constructor(name:String , amount:Number) {// this.name = name;// this.amount = amount;// }// }
classPerson{public name:string;publicconstructor(name:string){this.name = name
}}var p =newPerson("Jane Doe");console.log(p.name);/*for typescript, you need to not only specify the type in the normall places(e.g. constructor instead of name is name:string), but you also need to specify what the methods are above the constructor*//*not necessarily the recommended format for getting name, but at least this is gramatically correct*/
exportclassIngredient{//This is a shortcut to what is written below constructor(public name:String,public amount:String){}}// On top is the same as below //// export class Ingredient{// public name: String;// public amount: Number;// constructor(name:String , amount:Number) {// this.name = name;// this.amount = amount;// }// }
classPerson{private name:string;publicconstructor(name:string){this.name = name
}publicgetName():string{returnthis.name;}}var p =newPerson("Jane Doe");console.log(p.getName());/*this example is more proper than the previous, though the previous example is syntax-wise correct*/
classPerson{public name:string;publicconstructor(name:string){this.name = name
}}var p =newPerson("Jane Doe");console.log(p.name);/*for typescript, you need to not only specify the type in the normall places(e.g. constructor instead of name is name:string), but you also need to specify what the methods are above the constructor*//*not necessarily the recommended format for getting name, but at least this is gramatically correct*/
classInfo{private name:string;constructor(n:string){this.name = n ;};describe(){console.log(`Your name is ${this.name}`);}}const a =newInfo('joyous');
a.describe();
classPerson{private name:string;publicconstructor(name:string){this.name = name
}publicgetName():string{returnthis.name;}}var p =newPerson("Jane Doe");console.log(p.getName());/*this example is more proper than the previous, though the previous example is syntax-wise correct*/
exportclassIngredient{//This is a shortcut to what is written below constructor(public name:String,public amount:String){}}// On top is the same as below //// export class Ingredient{// public name: String;// public amount: Number;// constructor(name:String , amount:Number) {// this.name = name;// this.amount = amount;// }// }
classPerson{public name:string;publicconstructor(name:string){this.name = name
}}var p =newPerson("Jane Doe");console.log(p.name);/*for typescript, you need to not only specify the type in the normall places(e.g. constructor instead of name is name:string), but you also need to specify what the methods are above the constructor*//*not necessarily the recommended format for getting name, but at least this is gramatically correct*/
exportclassIngredient{//This is a shortcut to what is written below constructor(public name:String,public amount:String){}}// On top is the same as below //// export class Ingredient{// public name: String;// public amount: Number;// constructor(name:String , amount:Number) {// this.name = name;// this.amount = amount;// }// }
classPerson{private name:string;publicconstructor(name:string){this.name = name
}publicgetName():string{returnthis.name;}}var p =newPerson("Jane Doe");console.log(p.getName());/*this example is more proper than the previous, though the previous example is syntax-wise correct*/
classPerson{public name:string;publicconstructor(name:string){this.name = name
}}var p =newPerson("Jane Doe");console.log(p.name);/*for typescript, you need to not only specify the type in the normall places(e.g. constructor instead of name is name:string), but you also need to specify what the methods are above the constructor*//*not necessarily the recommended format for getting name, but at least this is gramatically correct*/