[기술면접]

유림·2022년 8월 26일
0

Tech interview

목록 보기
4/11

[inherit]

'class 접속하고싶은 대상 extends 부모요소' 형태로 상속받을 수 있다

[over-riding]

  • 부모 클래스의 메소드를 그대로 사용하고 싶지 않을 때 사용
  • 상속 받은 클래스에서 메소드를 원하는대로 변경해서 사용하는 것을 의미

[instanceof]

class를 object에 넣어주는 것 : 인스턴스화
클래스가 제대로 만들어졌는지 확인하는 용도
blooean의 true,false값으로 반환됨
const hyundai = new Car('hyundai', 'white');
const tesla = new ElecCar('tesla', 'red', 'electricity');
console.log(hyundai instanceof Car);
console.log(tesla instanceof Car);

두개 모두 true값이다
첫번째는 당연히 true이지만
두번째는 상속받아서 true가 출력된다

profile
ɪ ʜᴏᴘᴇ ᴛᴏ sᴏʟᴠᴇ ʀᴇᴀʟ ᴘʀᴏʙʟᴇᴍs👩🏻‍💻❤️

0개의 댓글