A couple language questions

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Ken Kast

    A couple language questions

    1) I want to test for the existence of a method o.m(), so I tried the line
    if (o.m) ...
    but the interpreter objects to the missing parentheses on m. (This is in
    IE.) What is an appropriate approach for checking the existing of a
    function?

    2) I've got the following code
    window.onresize = function {
    ....
    f();
    }
    function f() {
    ....
    }
    <BODY onload="f();">

    My question: if the resize event happens while f is executing, is the first
    call to f (onload) flushed from the stack? If not, where in f is execution
    resumed after the second call to f takes place in response to the resize
    event?

    Thanks.

    Ken


  • Janwillem Borleffs

    #2
    Re: A couple language questions


    "Ken Kast" <[email protected] m> wrote in message
    news:be1h4t$mjk [email protected] hgrum.com...[color=blue]
    > 1) I want to test for the existence of a method o.m(), so I tried the line
    > if (o.m) ...
    > but the interpreter objects to the missing parentheses on m. (This is in
    > IE.) What is an appropriate approach for checking the existing of a
    > function?
    >[/color]

    if (typeof o == 'object' && typeof o.m == 'function') {
    // Function exists
    }
    [color=blue]
    > 2) I've got the following code
    > window.onresize = function {
    > ...
    > f();
    > }
    > function f() {
    > ...
    > }
    > <BODY onload="f();">
    >[/color]

    window.onresize = f; // this is sufficient
    [color=blue]
    > My question: if the resize event happens while f is executing, is the[/color]
    first[color=blue]
    > call to f (onload) flushed from the stack? If not, where in f is[/color]
    execution[color=blue]
    > resumed after the second call to f takes place in response to the resize
    > event?
    >[/color]

    My guess is that the function will be called twice after the calls have been
    queued.


    JW



    Comment

    Working...