Search code examples
javascriptgwtjsni

GWT and JSNI. Check if function is defined


There is a JavaScript function in html

<script type="text/javascript">
function someFunction(){
    return "<b>some text</b>";
}      

And JSNI:

native String someFunction() /*-{
    return $wnd.someFunction();
}-*/;

The problem is that the first script is not allways defined. How can it be checked if function is defined?

Thank you in advance!


Solution

  • I'm not familiar with JSNI - but in JS you can do:

    if ( typeof someFunction == 'function' ) { ... }