Skip to content

Commit 2a7f882

Browse files
nimuseelViolet-Bora-Lee
authored andcommitted
[과제 누락 복구] 4.1 3번째 문제 누락된 것 복구
1 parent d9a7cf1 commit 2a7f882

File tree

2 files changed

+34
-0
lines changed

2 files changed

+34
-0
lines changed
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
당연히 에러 없이 실행됩니다.
2+
3+
`const`는 한 번이라도 값을 할당한 변수가 변경되는 걸 막습니다.
4+
5+
변수 `user`는 객체 참조 값을 저장하고 있는데, `const`는 이 값이 변경되는걸 막는 것이지, 객체의 내용(프로퍼티)을 변경하는 건 막지 않습니다.
6+
7+
```js run
8+
const user = {
9+
name: "John"
10+
};
11+
*!*
12+
// works
13+
user.name = "Pete";
14+
*/!*
15+
// error
16+
user = 123;
17+
```
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
importance: 5
2+
3+
---
4+
5+
# 변하지 않는 객체?
6+
7+
`const`와 함께 선언한 객체를 변경하는 게 가능할까요? 생각을 공유해주세요!
8+
9+
```js
10+
const user = {
11+
name: "John"
12+
};
13+
*!*
14+
// 아래 코드는 에러 없이 실행될까요?
15+
user.name = "Pete";
16+
*/!*
17+
```

0 commit comments

Comments
 (0)