Skip to content

How to prevent TypeError: is not a function? [closed]

What I’m trying to do is the inner code (result) will only work when there’s an attribute of Validity.
But since my target doesn’t have an attribute of Validity, I want to prevent the inner code to run by having an if checking.

What can I do to check/prevent the error of TypeError: is not a function?

enter image description here


use optional chaining or hasOwnProperty() method