Search
The following code throws an error because car2 does not have the property engine. Add optional chaining to car2.engine["turn-off"]() to make sure that the ["turn-off"]() method is only invoked if car2.engine exists.
car2
engine
car2.engine["turn-off"]()
["turn-off"]()
car2.engine
For example: