2020. 10. 1. 22:20, Developer
private 은 다접근 안됨.
protected는 부모자식에서만 됨.
class Parent{
private privateProp:string;
protected protectedProp:string;
constructor(){
}
}
class Child extends Parent{
constructor(){
super();
this.protectedProp='protected';
}
}
console.log(new Child());
==========================================================
class Person{
protected _name:string = 'kim';
private _age:number=null;
}
class Child extends Person{
setName(){
this._name='fuck';
}
}
const person:Child = new Child();
person.setName();
console.log(person);
'Developer' 카테고리의 다른 글
[typescript]class - 자식 생성자는 super를 꼭 가져야함 (0) | 2020.10.01 |
---|---|
[typescript]class - class안에 생성자의 private 변수 (0) | 2020.10.01 |
[typescript]class - private (0) | 2020.10.01 |
[typescript]interface-indexibel 은 string과 number 만 가능 (0) | 2020.10.01 |
[typescript]interface-함수를 프로퍼티로 (0) | 2020.10.01 |
Comments, Trackbacks