ok
This commit is contained in:
parent
b78f329c5f
commit
0818e61927
20 changed files with 264 additions and 163 deletions
19
1-js/4-object-basics/01-object/4-const-object/solution.md
Normal file
19
1-js/4-object-basics/01-object/4-const-object/solution.md
Normal file
|
@ -0,0 +1,19 @@
|
|||
Sure, it works, no problem.
|
||||
|
||||
The `const` only protects the variable itself from changing.
|
||||
|
||||
In other words, `user` stores a reference to the object. And it can't be changed. But the content of the object can.
|
||||
|
||||
```js run
|
||||
const user = {
|
||||
name: "John"
|
||||
};
|
||||
|
||||
*!*
|
||||
// works
|
||||
user.name = "Pete";
|
||||
*/!*
|
||||
|
||||
// error
|
||||
user = 123;
|
||||
```
|
18
1-js/4-object-basics/01-object/4-const-object/task.md
Normal file
18
1-js/4-object-basics/01-object/4-const-object/task.md
Normal file
|
@ -0,0 +1,18 @@
|
|||
importance: 5
|
||||
|
||||
---
|
||||
|
||||
# Constant objects?
|
||||
|
||||
Is it possible to change an object declared with `const`, how do you think?
|
||||
|
||||
```js
|
||||
const user = {
|
||||
name: "John"
|
||||
};
|
||||
|
||||
*!*
|
||||
// does it work?
|
||||
user.name = "Pete";
|
||||
*/!*
|
||||
```
|
Loading…
Add table
Add a link
Reference in a new issue