Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR TYPESCRIPT

typescript class interface

interface IPerson {
  name: string
  age: number
  hobby?: string[]
}

class Person implements IPerson {
  name: string
  age: number
  hobby?: string[]

  constructor(name: string, age: number, hobby: string[]) {
    this.name = name
    this.age = age
    this.hobby = hobby
  }
}

const output = new Person('john doe', 23, ['swimming', 'traveling', 'badminton'])
console.log(output)
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #typescript #class #interface
ADD COMMENT
Topic
Name
7+6 =