<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Call Back Function</title>
</head>
<body>
<h1>Students List</h1>
<ul id="name"></ul>
<script type="text/javascript">
const students = [
{name : "atul", subject : "Computer Science"},
{name : "ashish", subject : "Computer Network"}
]
function setStudents(something, callBack) {
setTimeout(function(){
students.push(something);
console.log("Student Updated");
callBack();
}, 3000);
}
function getStudents() {
setTimeout(function(){
var str = "";
students.forEach(function(args){
str = str + `<li>${args.name}</li>`
});
document.getElementById('name').innerHTML = str;
console.log("Hey showing Students");
}, 1000)
}
var jayega = {name : "pradeep", subject : "Android"}
setStudents(jayega, getStudents);
</script>
</body>
</html>
yaha par setStudent getStudent ko rok kar rakhega jabtak ki wo khud execute nahi ho jata