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
@@ -1276,7 +1287,7 @@ class Meeting extends CalendarItem {
1276
1287
}
1277
1288
```
1278
1289
1279
-
Take some time to read and digest those `class` definitions. Note which of the `class` features from this chapter that you see being used.
1290
+
Take some time to read and digest those `class` definitions. Did you spot most of the `class` features we talked about in this chapter?
1280
1291
1281
1292
| NOTE: |
1282
1293
| :--- |
@@ -1289,25 +1300,49 @@ var callMyParents = new Reminder(
1289
1300
"Call my parents to say hi",
1290
1301
newDate("July 7, 2022 11:00:00 UTC")
1291
1302
);
1303
+
callMyParents.toString();
1304
+
// [object Reminder]
1292
1305
callMyParents.summary();
1293
1306
// (586380912) Call my parents to say hi at
1294
1307
// Thu, 07 Jul 2022 11:00:00 GMT
1295
-
1296
1308
callMyParents.markComplete();
1297
1309
callMyParents.summary();
1298
1310
// (586380912) Complete.
1311
+
callMyParents instanceof Reminder;
1312
+
// true
1313
+
callMyParents instanceof CalendarItem;
1314
+
// true
1315
+
callMyParents instanceof Meeting;
1316
+
// false
1317
+
1299
1318
1300
1319
var interview =newMeeting(
1301
1320
"Job Interview: ABC Tech",
1302
1321
newDate("June 23, 2022 08:30:00 UTC"),
1303
1322
newDate("June 23, 2022 09:15:00 UTC")
1304
1323
);
1324
+
interview.toString();
1325
+
// [object Meeting]
1305
1326
interview.summary();
1306
1327
// (994337604) Job Interview: ABC Tech at Thu,
1307
1328
// 23 Jun 2022 08:30:00 GMT - Thu, 23 Jun 2022
1308
1329
// 09:15:00 GMT
1330
+
interview instanceof Meeting;
1331
+
// true
1332
+
interview instanceof CalendarItem;
1333
+
// true
1334
+
interview instanceof Reminder;
1335
+
// false
1336
+
1337
+
1338
+
Reminder.isSameItem(callMyParents,callMyParents);
1339
+
// true
1340
+
Meeting.isSameItem(callMyParents,interview);
1341
+
// false
1309
1342
```
1310
1343
1344
+
Admittedly, some bits of this example are a little contrived. But honestly, I think pretty much all of this is plausible and reasonable usages of the various `class` features.
1345
+
1311
1346
By the way, there's probably a million different ways to structure the above code logic. I'm by no means claiming this is the *right* or *best* way to do so. As an exercise for the reader, try your hand and writing it yourself, and take note of things you did differently than my approach.
1312
1347
1313
1348
[^POLP]: *Principle of Least Privilege*, https://en.wikipedia.org/wiki/Principle_of_least_privilege, 15 July 2022.
0 commit comments