Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Fix minor grammatical errors#3410

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Open
kristenmazza wants to merge2 commits intojavascript-tutorial:master
base:master
Choose a base branch
Loading
fromkristenmazza:fix-grammar-errors
Open
Changes fromall commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions1-js/07-object-properties/02-property-accessors/article.md
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -34,7 +34,7 @@ let user = {
};
```

Now we want to add a `fullName` property,that should be `"John Smith"`. Of course, we don't want to copy-paste existing information, so we can implement it as an accessor:
Now we want to add a `fullName` property,which should be `"John Smith"`. Of course, we don't want to copy-paste existing information, so we can implement it as an accessor:

```js run
let user = {
Expand DownExpand Up@@ -104,10 +104,10 @@ For accessor properties, there is no `value` or `writable`, but instead there ar

That is, an accessor descriptor may have:

- **`get`** -- a function without arguments, that works when a property is read,
- **`set`** -- a function with one argument, that is called when the property is set,
- **`enumerable`** -- same as for data properties,
- **`configurable`** -- same as for data properties.
- **`get`** -- a function without arguments that works when a property is read
- **`set`** -- a function with one argument that is called when the property is set
- **`enumerable`** -- same as for data properties
- **`configurable`** -- same as for data properties

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

might suggest dropping punctuation at end of bullets as well:

  • get -- a function without arguments that works when a property is read
  • set -- a function with one argument that is called when the property is set
  • enumerable -- same as for data properties
  • configurable -- same as for data properties

kristenmazza reacted with thumbs up emoji
For instance, to create an accessor `fullName` with `defineProperty`, we can pass a descriptor with `get` and `set`:

Expand DownExpand Up@@ -185,7 +185,7 @@ Technically, external code is able to access the name directly by using `user._n

## Using for compatibility

One of the great uses of accessors is that they allow to take control over a "regular" data property at any moment by replacing it with a getter and a setter andtweak its behavior.
One of the great uses of accessors is that they allowusto take control over a "regular" data property at any moment by replacing it with a getter and a setter andtweaking its behavior.

Imagine we started implementing user objects using data properties `name` and `age`:

Expand DownExpand Up@@ -241,4 +241,4 @@ alert( john.birthday ); // birthday is available
alert( john.age ); // ...as well as the age
```

Now the old code works too and we've got a nice additional property.
Now the old code works too, and we've got a nice additional property.

[8]ページ先頭

©2009-2025 Movatter.jp