How can I check if function exists on window.exter

2019-07-11 07:39发布

问题:

How can I check if function exists on window.external?

I'm calling C# code from javascript and I want to check if a method exists in the C# object.

回答1:

I found the way, Just using the 'in' operator like this:

if ('FunctionName' in window.external){
    window.external.FunctionName(...);
}