How is it possible for the Javascript function to be undefined and still available for calling?

When I write

window.external.AddSearchProvider

in Internet Explorer 11 I get "undefined", but I can still call and use the function. Although in Chrome, the method is defined and applicable.

If i write

"AddSearchProvider" in window.external

I get "true" in both Internet Explorer and Chrome.

Is this the expected behavior? I was under the impression that I can check if I can use the function, checking if it was determined, or is this what I misunderstood?

+4
source share
2 answers

window.external.AddSearchProvideris not a "simple" javascript function. This is a built-in feature provided by the browser, and each browser handles it differently.

window.external.AddSearchProvider javascript , javascript . , , Internet Explorer , undefined, . .

,

toJavascriptValue : function() {
    return undefined;
}
+2

https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/in

in true, .

Addsearchprovider - window.external. in , window.external . Addsearchprovider

window.external.AddSearchProvider() - . window.external.AddSearchProvider, .

window.external.AddSearchProvider() window.external.AddSearchProvider .

-1

Source: https://habr.com/ru/post/1610282/


All Articles