Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR TYPESCRIPT

Class In TypeScript

class Person{


  public name: string;


  public constructor(name: string)
  {
this.name = name

  }
 }
 
var p =  new Person("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*/
Source by www.codegrepper.com #
 
PREVIOUS NEXT
Tagged: #Class #In #TypeScript
ADD COMMENT
Topic
Name
9+7 =