Comments (4)
Q1. ?에 들어갈 값은 무엇일까요? 오버라이딩과 프로퍼티 섀도잉에 대해서도 설명해 주세요.
const Person = (function () {
function Person(name) {
this.name = name;
}
Person.prototype.sayHello = function() {
console.log(`Hi! My Name is ${this.name}`);
}
return Person;
}());
const me = new Person('Lee');
me.sayHello = function() {
console.log(`Hey! My Name is ${this.name}`)
}
me.sayHello(); // ?
정답
오버라이딩은 상위 클래스가 가지고 있는 메서드를 하위 클래스가 재정의하여 사용하는 방식을 말한다. 프로퍼티 섀도잉은 상속 관계에 의해 프로퍼티가 가려지는 현상을 말한다.
인스턴스 메서드 sayHello는 프로토타입 메서드 sayHello를 오버라이딩 했고, 프로토타입 메서드 sayHello는 프로퍼티 섀도잉에 의해 가려지기 때문에 me 객체의 sayHello가 동작한다.
from js-deep-dive-study.
Q1. 다음 코드의 결과를 쓰시오
function Study(subject) {
this.subject = subject
}
Study.prototype.getStudySubject = function () {
console.log(`Today's Study is ${this.subject}`);
}
Study.person = 'dongwoo';
Study.getPerson = function () {
console.log(this.person)
}
const jsStudy = new Study('javaScript');
Stduy.getPerson(); // -> ?
jsStudy.getPerson(); // -> ?
정답
1. dongwoo- TypeError
생성자 함수에 직접 추가한 정적 프로퍼티나 메소드는
생성자 함수로만 참조/호출할 수 있다.
from js-deep-dive-study.
Q1. 출력된 결과와 이유를 적어주세요
function Person(name) {
this.name = name
}
const me = new Person('Lee')
console.log(me instanceof Person); // <- 1.
console.log(me instanceof Object); // <- 2.
정답
from js-deep-dive-study.
Q1. __ proto __ 접근자 프로퍼티를 코드 내에서 직접 사용하는 것을 권장하지 않는 이유를 설명해주세요.
정답
Q2. 프로토타입 체인에 대해 설명해주세요.
정답
from js-deep-dive-study.
Related Issues (20)
- [21장] 빌트인 객체 HOT 5
- [22장] this HOT 5
- [23장] 실행 컨텍스트 HOT 5
- [24장] 클로저 HOT 5
- [25장] 클래스 HOT 5
- [26장] ES6 함수의 추가 기능 HOT 5
- [33장] 7번째 데이터 타입 Symbol HOT 3
- [34장] 이터러블 HOT 3
- [35장, 36장] 스프레드 문법, 디스트럭처링 할당 HOT 3
- [37장] Set과 Map HOT 2
- [38장] 브라우저의 렌더링 과정 HOT 3
- [39장] DOM HOT 3
- [40장] 이벤트 HOT 4
- [41장, 42장] 타이머, 비동기 프로그래밍 HOT 4
- [43장] Ajax HOT 4
- [44장] REST API HOT 4
- [45장] 프로미스 HOT 2
- [46장] 제너레이터와 async/await HOT 1
- [47장] 에러처리 HOT 1
- [48장] 모듈 HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from js-deep-dive-study.