Javascript examples for Function:Function Definition
Run part of a function only once until it's allowed to do otherwise
<html> <head></head> <body> <button>Click Me</button> <script> var firstTime = true;//from www . j a v a 2 s. co m function myfunc(){ if(firstTime){ console.log("Triggering for the first time"); firstTime = false; } console.log("Hi, How are you?"); } document.querySelector("button").onclick = myfunc; </script> </body> </html>