minor
This commit is contained in:
parent
d36675ed33
commit
cd2c7ce3c8
1 changed files with 3 additions and 3 deletions
|
@ -1,11 +1,11 @@
|
|||
|
||||
# Property getters and setters
|
||||
|
||||
There are two kinds of properties.
|
||||
There are two kinds of object properties.
|
||||
|
||||
The first kind is *data properties*. We already know how to work with them. All properties that we've been using until now were data properties.
|
||||
|
||||
The second type of properties is something new. It's *accessor properties*. They are essentially functions that work on getting and setting a value, but look like regular properties to an external code.
|
||||
The second type of properties is something new. It's *accessor properties*. They are essentially functions that execute on getting and setting a value, but look like regular properties to an external code.
|
||||
|
||||
## Getters and setters
|
||||
|
||||
|
@ -53,7 +53,7 @@ alert(user.fullName); // John Smith
|
|||
*/!*
|
||||
```
|
||||
|
||||
From outside, an accessor property looks like a regular one. That's the idea of accessor properties. We don't *call* `user.fullName` as a function, we *read* it normally: the getter runs behind the scenes.
|
||||
From the outside, an accessor property looks like a regular one. That's the idea of accessor properties. We don't *call* `user.fullName` as a function, we *read* it normally: the getter runs behind the scenes.
|
||||
|
||||
As of now, `fullName` has only a getter. If we attempt to assign `user.fullName=`, there will be an error:
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue