@@ -741,11 +741,11 @@ class Airplane {
741
741
getCruisingAltitude () {
742
742
switch (this .type ) {
743
743
case ' 777' :
744
- return getMaxAltitude () - getPassengerCount ();
744
+ return this . getMaxAltitude () - this . getPassengerCount ();
745
745
case ' Air Force One' :
746
- return getMaxAltitude ();
746
+ return this . getMaxAltitude ();
747
747
case ' Cessna' :
748
- return getMaxAltitude () - getFuelExpenditure ();
748
+ return this . getMaxAltitude () - this . getFuelExpenditure ();
749
749
}
750
750
}
751
751
}
@@ -760,21 +760,21 @@ class Airplane {
760
760
class Boeing777 extends Airplane {
761
761
// ...
762
762
getCruisingAltitude () {
763
- return getMaxAltitude () - getPassengerCount ();
763
+ return this . getMaxAltitude () - this . getPassengerCount ();
764
764
}
765
765
}
766
766
767
767
class AirForceOne extends Airplane {
768
768
// ...
769
769
getCruisingAltitude () {
770
- return getMaxAltitude ();
770
+ return this . getMaxAltitude ();
771
771
}
772
772
}
773
773
774
774
class Cessna extends Airplane {
775
775
// ...
776
776
getCruisingAltitude () {
777
- return getMaxAltitude () - getFuelExpenditure ();
777
+ return this . getMaxAltitude () - this . getFuelExpenditure ();
778
778
}
779
779
}
780
780
```
@@ -1006,12 +1006,12 @@ class UserSettings {
1006
1006
}
1007
1007
1008
1008
changeSettings (settings ) {
1009
- if (this .verifyCredentials (user )) {
1009
+ if (this .verifyCredentials ()) {
1010
1010
// ...
1011
1011
}
1012
1012
}
1013
1013
1014
- verifyCredentials (user ) {
1014
+ verifyCredentials () {
1015
1015
// ...
1016
1016
}
1017
1017
}
@@ -1406,35 +1406,35 @@ classes until you find yourself needing larger and more complex objects.
1406
1406
** Bad:**
1407
1407
``` javascript
1408
1408
const Animal = function (age ) {
1409
- if (! (this instanceof Animal)) {
1410
- throw new Error (" Instantiate Animal with `new`" );
1411
- }
1409
+ if (! (this instanceof Animal)) {
1410
+ throw new Error (" Instantiate Animal with `new`" );
1411
+ }
1412
1412
1413
- this .age = age;
1413
+ this .age = age;
1414
1414
};
1415
1415
1416
1416
Animal .prototype .move = function () {};
1417
1417
1418
1418
const Mammal = function (age , furColor ) {
1419
- if (! (this instanceof Mammal)) {
1420
- throw new Error (" Instantiate Mammal with `new`" );
1421
- }
1419
+ if (! (this instanceof Mammal)) {
1420
+ throw new Error (" Instantiate Mammal with `new`" );
1421
+ }
1422
1422
1423
- Animal .call (this , age);
1424
- this .furColor = furColor;
1423
+ Animal .call (this , age);
1424
+ this .furColor = furColor;
1425
1425
};
1426
1426
1427
1427
Mammal .prototype = Object .create (Animal .prototype );
1428
1428
Mammal .prototype .constructor = Mammal;
1429
1429
Mammal .prototype .liveBirth = function () {};
1430
1430
1431
1431
const Human = function (age , furColor , languageSpoken ) {
1432
- if (! (this instanceof Human)) {
1433
- throw new Error (" Instantiate Human with `new`" );
1434
- }
1432
+ if (! (this instanceof Human)) {
1433
+ throw new Error (" Instantiate Human with `new`" );
1434
+ }
1435
1435
1436
- Mammal .call (this , age, furColor);
1437
- this .languageSpoken = languageSpoken;
1436
+ Mammal .call (this , age, furColor);
1437
+ this .languageSpoken = languageSpoken;
1438
1438
};
1439
1439
1440
1440
Human .prototype = Object .create (Mammal .prototype );
@@ -1445,29 +1445,29 @@ Human.prototype.speak = function() {};
1445
1445
** Good:**
1446
1446
``` javascript
1447
1447
class Animal {
1448
- constructor (age ) {
1449
- this .age = age;
1450
- }
1448
+ constructor (age ) {
1449
+ this .age = age;
1450
+ }
1451
1451
1452
- move () {}
1452
+ move () { /* ... */ }
1453
1453
}
1454
1454
1455
1455
class Mammal extends Animal {
1456
- constructor (age , furColor ) {
1457
- super (age);
1458
- this .furColor = furColor;
1459
- }
1456
+ constructor (age , furColor ) {
1457
+ super (age);
1458
+ this .furColor = furColor;
1459
+ }
1460
1460
1461
- liveBirth () {}
1461
+ liveBirth () { /* ... */ }
1462
1462
}
1463
1463
1464
1464
class Human extends Mammal {
1465
- constructor (age , furColor , languageSpoken ) {
1466
- super (age, furColor);
1467
- this .languageSpoken = languageSpoken;
1468
- }
1465
+ constructor (age , furColor , languageSpoken ) {
1466
+ super (age, furColor);
1467
+ this .languageSpoken = languageSpoken;
1468
+ }
1469
1469
1470
- speak () {}
1470
+ speak () { /* ... */ }
1471
1471
}
1472
1472
```
1473
1473
** [ ⬆ back to top] ( #table-of-contents ) **
0 commit comments