TIL(03.26/ 2W 4D/Thur)

Seokhwan Yi·2020년 3월 26일
0

TIL

목록 보기
8/9
post-thumbnail

Inheritance Pattern

npm install : dependency 설치
ES6: super, extends, class
pseudoclassical: prototype, constructor, Object.create()
npm test : test

BeeBeesBees

꿀벌 패턴 만들기!
각 단계별로 꿀벌 Class가 있어서 역할마다 맡은 역할(method)들이 다르다.

Bare Minimum Requirements

Structure

├── Grub
│   └── Bee
│       ├── HoneyMakerBee
│       └── ForagerBee

Requirements

Subclass Dance Party

dance party

polymorphism 구현하기.
DOM과 CSS를 연습하기.

Refactoring

  • functional instantiation => ES6

Bare Minimum Requirements

  • Dancer, BlinkyDancer를 pseudocalssical과 ES6 class로 리팩토링하기
  • 두종류의 dancer파일 dancefloor.html에 추가.
  • CSS, JS 맘껏 적용해보기
  • lineUp 이라는 메소드 만들기 (버튼클릭시, 모든 댄서들의 lineUp 메소드 호출
  • init.js에 전역배열(dancer)이 하나 있다. 여기에 댄서 인스턴스를 추가하면, 배열의 반복을 통해 전부를 한번에 관리 가능

Checkpoint Solution

//1.
Student.prototype = Person.prototype(reference copy, 주소 연결) 단순히 객체와 객체의 대입. Person을 바라보고 있음.

//2.
Student.prototype = Object.create(Person.prototype);(reference참조가 일어나는데 조금 다름, deepcopy가 아님.)
proto : value[Person.prototype] key:value 타입으로 돌아감.

//3.
다형성 . 대체 가능성 , 부모 객체를 자식 객체에 대체 할 수 있다.

//4.
this는 함수 를 나타낸다. 실행 컨텍스트 => this.name = "" 하면 속성을 부여 하며 객체로 만들수 있다.
new 키워드를 써서 객체를 만들어도 함수는 실행된다.!!

profile
위대한 한잔을 좋아 합니다.

0개의 댓글