2 Replies Latest reply on Apr 23, 2006 8:18 PM by Newsgroup_User

    setInterval or setTimeout returning values

    DuhChamp Level 1
      Is it possible for setTimeout or setInterval to use functions that return values? If so, how would it look code-wise?
        • 1. Re: setInterval or setTimeout returning values
          Level 7
          > Is it possible for setTimeout or setInterval to use functions that return
          > values? If so, how would it look code-wise?

          No.. any return value is ignored.
          --
          jeckyl


          • 2. Re: setInterval or setTimeout returning values
            Level 7
            DuhChamp wrote:

            > Is it possible for setTimeout or setInterval to use functions that return
            > values? If so, how would it look code-wise?

            If you mean "can I invoke a function that returns a value in a
            setInterval?" , the answer is yes and the syntax is the same as when you
            use a function that does not return a value.

            if you mean "can I use the return value of a function from inside the
            setInterval call?", answer is no, the return value will be discarded. To
            achieve that, you have to use a more sophisticated approach. For example,
            invoke setInterval with a wrapper function that calls your target function
            and does something with the return value.

            Tim.