Have you ever seen this error: “TypeError: xxx is not a function”? This error occurs when you try to call a function that does not exist.
1 | const person = { |
You can solve this by the optional chaining
operator ?.
:
1 | person.getAge?.(); // nothing output |
However, if there is a property in the object has the same name by accident, you will still get that error
1 | const person = { |