Skip to content

Commit dd106ba

Browse files
committed
class
1 parent e7d6d4a commit dd106ba

File tree

1 file changed

+2
-20
lines changed

1 file changed

+2
-20
lines changed

1-js/09-classes/01-class/article.md

Lines changed: 2 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -232,7 +232,7 @@ new User().sayHi(); // Hello
232232
233233
## Getters/setters, other shorthands
234234
235-
Classes also include getters/setters, generators, computed properties etc.
235+
Just like literal objects, classes may include getters/setters, generators, computed properties etc.
236236
237237
Here's an example for `user.name` implemented using `get/set`:
238238

@@ -325,24 +325,6 @@ The property is not placed into `User.prototype`. Instead, it is created by `new
325325

326326
## Summary
327327

328-
JavaScript provides many ways to create a class.
329-
330-
First, as per the general object-oriented terminology, a class is something that provides "object templates", allows to create same-structured objects.
331-
332-
When we say "a class", that doesn't necessary means the `class` keyword.
333-
334-
This is a class:
335-
336-
```js
337-
function User(name) {
338-
this.sayHi = function() {
339-
alert(name);
340-
}
341-
}
342-
```
343-
344-
...But in most cases `class` keyword is used, as it provides great syntax and many additional features.
345-
346328
The basic class syntax looks like this:
347329

348330
```js
@@ -363,6 +345,6 @@ class MyClass {
363345
}
364346
```
365347

366-
`MyClass` is technically a function, while methods are written to `MyClass.prototype`.
348+
`MyClass` is technically a function (the one that we provide as `constructor`), while methods, getters and settors are written to `MyClass.prototype`.
367349

368350
In the next chapters we'll learn more about classes, including inheritance and other features.

0 commit comments

Comments
 (0)