@@ -232,7 +232,7 @@ new User().sayHi(); // Hello
232
232
233
233
## Getters/setters, other shorthands
234
234
235
- Classes also include getters/setters, generators, computed properties etc.
235
+ Just like literal objects, classes may include getters/setters, generators, computed properties etc.
236
236
237
237
Here' s an example for ` user.name` implemented using ` get/set` :
238
238
@@ -325,24 +325,6 @@ The property is not placed into `User.prototype`. Instead, it is created by `new
325
325
326
326
## Summary
327
327
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
-
346
328
The basic class syntax looks like this:
347
329
348
330
` ` ` js
@@ -363,6 +345,6 @@ class MyClass {
363
345
}
364
346
` ` `
365
347
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`.
367
349
368
350
In the next chapters we'll learn more about classes, including inheritance and other features.
0 commit comments