The setTimeout() method sets a timer which executes a function or specified
piece of code once after the timer expires. The function is only executed once. It returns a positive integer value which identifies the timer created by the call to setTimeout(); this value can be passed to clearTimeout() to cancel the timeout. Syntax: - setTimeout (function, milliseconds, para1, para2); Ex: - var timeoutID = setTimeout(show, 2000); clearTimeout( ) Method The clearTimeout() method cancels a timeout previously established by calling setTimeout(). The ID value returned by setTimeout() is used as the parameter for the clearTimeout() method. Syntax: - clearTimeout (timeoutID); Ex: - clearTimeout(timeoutID); setInterval( ) Method The setInterval() method repeatedly calls a function or executes a code snippet, with a fixed time delay between each call. It returns an interval ID which uniquely identifies the interval, so you can remove it later by calling clearInterval(). Syntax: - setInterval (function, milliseconds, para1, para2); Ex: - var intervalID = setInterval(show, 2000); clearInterval( ) Method The clearInterval() method cancels a timed, repeating action which was previously established by a call to setInterval(). Syntax: - clearInterval (intervalID); Ex: - clearInterval(intervalID);
Computer Architecture Course: IT089IU International University - VNU HCM Date: March 2021 Dr. Le Hai Duong & Dr. Ly Tu Nga Time: 6 hours Trần Minh Duy ITITIU18230