|
41 | 41 | - `typeof` returns a string. |
42 | 42 | - You can check the length of an array to find out how many elements it contains. |
43 | 43 |
|
44 | | -## 8. Throw an error if an object does not have the `id` property |
| 44 | +## 8. Throw an error if an object does not have the `id` property or method |
45 | 45 |
|
46 | | -- You can use the `in` operator or the `Object.hasOwn()` function to check if an object has a property. |
47 | | -- If the `id` property is missing, your function should throw an `Error`. |
| 46 | +- You can use the `in` operator to check if an object has a property or method. |
| 47 | +- If the `id` property or method is missing, your function should throw an `Error`. |
48 | 48 |
|
49 | | -## 9. Check if an object has a `type` property |
| 49 | +## 9. Check if an object has a `type` property or method |
50 | 50 |
|
51 | | -- You can use the `in` operator or the `Object.hasOwn()` function to check if an object has a property. |
| 51 | +- You can use the `in` operator to check if an object has a property or method. |
52 | 52 |
|
53 | | -## 10. Check if an object has a `constructor` property |
| 53 | +## 10. Check if an object has an `id` property |
54 | 54 |
|
55 | | -- All class instances have a `constructor`, but `Object.hasOwn()` is able to ignore this. |
| 55 | +- To check if an object has a property (not a method), you can use the `Object.hasOwn()` function. |
56 | 56 |
|
57 | 57 | ## 11. Check if an object has a defined `type` property |
58 | 58 |
|
59 | | -- You can use the `in` operator or the `Object.hasOwn()` function to check if an object has a property. |
| 59 | +- To check if an object has a property (not a method), you can use the `Object.hasOwn()` function. |
60 | 60 | - You will have to access the `type` property and check if it is defined. |
61 | 61 |
|
62 | 62 | [isNaN]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/isNaN |
0 commit comments