« Back to the index

Function.prototype.delay examples

The "delay" method allow the programmer to retard the call to a function:
function.delay(timer, parameters);
The "timer" is an integer, the quantity of miliseconds to delay the call of the function.
The parameters are the list of each parameter to send to the main funcion.
This function is very usefull to call a delayed function with specific parameters, without having to use a specific timer.

Let's use a basic function that makes a simple alert:
function test(message) { alert(message); } <!-- the button: --> <span class="button" onclick="test('An alert message');">Call the normal function</span>
Call the normal function
<!-- the button: --> <span class="button" onclick="test.delay(2000, 'A delayed alert message');">Call the delayed function (2s)</span>
Call the delayed function (2s)

« Back to the index