Javascript examples for Array Operation:Array Element
Create timer (setTimeout) array and use them one by one
<html> <head> <meta name="viewport" content="width=device-width, initial-scale=1"> <script type="text/javascript"> var myTimer = [];/*from w w w . j a va2 s .com*/ function myFunction () { myTimer.push(setTimeout(function(){console.log("Hello")},3000)); } function myStopFunction () { clearTimeout(myTimer.pop()); } </script> </head> <body> <button onclick="myFunction()">Try it</button> <button onclick="myStopFunction()">Stop the alert</button> </body> </html>