자주 헷갈릴 수 있는 개념이라 표로 정리해둔다. Element Overriding Overloading Declaration Sub Class equivalent Class Relationship Parent - Child Class (Inheritance) equivalent Goal same method name but specially optimized at sub class same method name and Polymorphism(ex. different parameter type -> different return type) Condition Same Parameter type, the number of parameter Different Parameter (number, type..) Bi..
Method
1. 소스 코드 문제점 제시 다음 코드를 보고 문제점을 짚어보자 모든 학생 객체가 show_info, get_total_sum, get_average라는 메소드가 같은 기능을 하는데도 불구하고 별도의 메모리를 다 할당받는다. (메모리 낭비 쓰레기..) 개개인의 이름, 수학, 영어 점수는 다르지만 "모든 객체가 공통의 메소드를 공유할 수 없을까?" 에서 나온것이 Prototype Method! 메모리 절약에 아주 특효약 Javascript는 이 프로토타입을 생성하기를 적극 권장하는 언어이고 대부분의 API 보면 Prototype이 아주 자주 등장한다. 모든 Javascript 메소드는 Prototype Object를 갖는다. 객체별 메소드 재정의가 용이하여 메소드를 커스터마이징 할 수 있어 유지보수에도 유..