Life Developer
인생 개발자
[typescript]Generic class

class Person<T>{

    private _name:T;

 

    constructor(name:T){

        this._name=name;

    }

}

 

const kim = new Person('gibeom');

const age = new Person(123);

 

console.log(kim);

console.log(age);

'Developer' 카테고리의 다른 글

[typescript]Generic type - 2개이상 타입  (0) 2020.10.02
[typescript]Generic type - 상속  (0) 2020.10.02
[typescript]Generic  (0) 2020.10.02
[typescript]class - readonly  (0) 2020.10.01
[typescript]class - getter와 setter  (0) 2020.10.01
  Comments,     Trackbacks