Function setTimeout

  • Sets a timer which executes a function once after the delay (in milliseconds) elapses. Returns an id which may be used to cancel the timeout.

    note: only js2.0 support

    setTimeout(() => { console.log('hello'); }, 500);
    

    Parameters

    • cb: ((...args) => void)

      callback function to execute when timer expires

        • (...args): void
        • Parameters

          • Rest ...args: any[]

          Returns void

    • Optional delay: number

      delay in ms

    • Rest ...args: any[]

      arguments passed to callback function

    Returns number