You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: exercises/concept/windowing-system/.docs/introduction.md
+10-10
Original file line number
Diff line number
Diff line change
@@ -2,12 +2,12 @@
2
2
3
3
JavaScript includes the capabilities for object-oriented programming ([OOP][wiki-oop]).
4
4
In OOP, you want to create objects (_instances_) from "templates" (_classes_) so that they include certain data and functionality.
5
-
The data properties are called _fields_ in the OOP context, function properties are called _methods_.
5
+
The data properties are called _fields_ in the OOP context, the function properties are called _methods_.
6
6
7
7
JavaScript did not have classes at all before they were added to the language specification in 2015 but allowed for object-oriented programming using prototype-based inheritance.
8
8
And even though a `class` keyword is available nowadays, JavaScript is still a _prototype-based_ language.
9
9
10
-
To understand what it means to be a prototype-based language and how JavaScript works, we will go back to the time when there were no classes.
10
+
To understand what it means to be a prototype-based language and how JavaScript actually works, we will go back to the time when there were no classes.
11
11
12
12
## Prototype Syntax
13
13
@@ -184,24 +184,24 @@ With the keywords `get` and `set` you can define functions that are executed whe
184
184
```javascript
185
185
classCar {
186
186
constructor() {
187
-
this._milage=0;
187
+
this._mileage=0;
188
188
}
189
189
190
-
getmilage() {
191
-
returnthis._milage;
190
+
getmileage() {
191
+
returnthis._mileage;
192
192
}
193
193
194
-
setmilage(value) {
195
-
thrownewError(`Milage cannot be manipulated, ${value} is ignored.`);
194
+
setmileage(value) {
195
+
thrownewError(`Mileage cannot be manipulated, ${value} is ignored.`);
196
196
// Just an example, usually you would not provide a setter in this case.
197
197
}
198
198
}
199
199
200
200
constmyCar=newCar();
201
-
myCar.milage;
201
+
myCar.mileage;
202
202
// => 0
203
-
myCar.milage=100;
204
-
// => Error: Milage cannot be manipulated, 100 is ignored.
203
+
myCar.mileage=100;
204
+
// => Error: Mileage cannot be manipulated, 100 is ignored.
0 commit comments