JavaScript - 문제 미리보기
문제 615
medium
다음 `Object.create()` 코드의 실행 결과는?
```javascript
const person = {
firstName: "John",
lastName: "Doe",
language: "EN"
};
const man = Object.create(person);
man.firstName = "Peter";
console.log(person.firstName + " and " + man.firstName);
```
```javascript
const person = {
firstName: "John",
lastName: "Doe",
language: "EN"
};
const man = Object.create(person);
man.firstName = "Peter";
console.log(person.firstName + " and " + man.firstName);
```
정답: C
`Object.create(person)`은 `person` 객체를 프로토타입으로 하는 새로운 객체 `man`을 생성합니다. `man.firstName = "Peter"`는 `man` 객체에만 새로운 `firstName` 속성을 추가하므로 원본 `person` 객체는 변경되지 않습니다. 따라서 `person.firstName`은 여전히 "John"이고, `man.firstName`은 "Peter"가 됩니다.
💡 학습 팁
이 문제를 포함한 JavaScript 과목의 모든 문제를 순차적으로 풀어보세요. 진행상황이 자동으로 저장되어 언제든지 이어서 학습할 수 있습니다.