Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR TYPESCRIPT

typescript reset class properties to default

export class Product{
  productId: number; 
  productName: string = "Apple";
  productDescription: string;
  sideProducts: Array;

  reset() {
    this.productId = 0; //default of number datatype is 0
    this.productName = "Apple";
    this.productDescription = null;
    this.sideProducts = [];
  }
}
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #typescript #reset #class #properties #default
ADD COMMENT
Topic
Name
7+1 =