-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcallBackFunction.js
More file actions
34 lines (29 loc) · 859 Bytes
/
callBackFunction.js
File metadata and controls
34 lines (29 loc) · 859 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
//* Call Back Function :
//? a function passing a function as a parameter
//? And this called callback function means that when we required that function we can callback it to execute
//ex
setTimeout(function () {
console.log("after 5 sec print it");
}, 5000);
function x(z) {
console.log("Hello");
z();
}
x(function y() {
console.log("world");
});
var document;
function evvent() {
let count = 0;
document.getElementById("btn").addEventListener("click", function xyz() {
var res = Number(++count); // Convert the counting from string to Number
function tx() {
document.querySelector("#txt").textContent = res; // Display on the hreading tag
}
tx();
});
}
evvent();
//Garbage Collections and Remove EventListeners
//Event listeners are heavy to control this we have Garbage collecctor in JS
//Events takes more memory