Practical - 3
Aim:
Implement a JS program which demonstrates the use of JavaScript functions and function closure.
CODE:
FILE HTML(P_3.HTML)
<html lang="en">
<head>
</head>
<body>
<h3>javascript function flow with closure</h3>
<button onclick="countclick()"> hello bhaiya yha click krna </button>
<script>
function createcounter(){
let count=0;
return function(){
count++;
alert("count numbers"+count);
};
}
let countclick=createcounter() ;
</script>
</body>
</html>
25012011139_TAHIR BHATI 13
Aim:
Implement a JS program which demonstrates the use of JavaScript functions and function closure.
CODE:
FILE HTML(P_3.HTML)
<html lang="en">
<head>
</head>
<body>
<h3>javascript function flow with closure</h3>
<button onclick="countclick()"> hello bhaiya yha click krna </button>
<script>
function createcounter(){
let count=0;
return function(){
count++;
alert("count numbers"+count);
};
}
let countclick=createcounter() ;
</script>
</body>
</html>
25012011139_TAHIR BHATI 13