What is callback function in JavaScript?

0 votes
What is the use of callback function used in angularjs? Does it play any important role in designing web page?
Jan 30 in Java-Script by kartik
• 31,730 points

recategorized Jan 31 by Niroj 2,077 views

1 answer to this question.

0 votes
  • callback is not a keyword, its just a name of parameter that is passed into the function, you can call it whatever you want (callback or cb is pretty common).

  • Callback function is a function which is passed to a function as parameter and is executed when the outer function is completed.
  •  Callbacks are a feature of JavaScript not particularly angularjs. Its a way to send a function as a parameter to the callee so that the callee call that function once the task is finished.
  • Example of callback function:
    function useAsCallback(string){
      console.log("callback is being executed with passed parameter: " + string)
    }
    
    function main(param, callback){
      callback(param)
    }
    
    main(123456, useAsCallback)
  • I found this website to be useful for learning ANGULARJS . Have a look at the site. Hope it helps.    https://www.edureka.co/masters-program/full-stack-developer-training
answered Jan 30 by Niroj
• 68,780 points

Related Questions In Java-Script

0 votes
1 answer

How to pass an array as a function parameter in JavaScript?

Hello @kartik, Use: const args = ['p0', 'p1', 'p2']; call_me.apply(this, ...READ MORE

answered Sep 4 in Java-Script by Niroj
• 68,780 points
65 views
0 votes
1 answer

How to Determine if page is valid in JavaScript - ASP.NET?

Hello @kartik,  Make the call on an input ...READ MORE

answered Sep 9 in Java-Script by Niroj
• 68,780 points
79 views
0 votes
1 answer

What are XMLHttpRequest Object in Ajax?

 As, you are up to ajax so ...READ MORE

answered Jan 31 in Java-Script by Niroj
• 68,780 points
74 views
0 votes
1 answer

what is the $(document).ready equivalent without jQuery?

Hello @kartik, There are three options: If script is the last ...READ MORE

answered Apr 2 in Java-Script by Niroj
• 68,780 points
1,375 views
+1 vote
1 answer

What is the relationship between angularjs Scope with controller/view?

Let us consider the below block: <div ng-controller="emp"> ...READ MORE

answered Jan 20 in Web Development by Niroj
• 68,780 points

edited Jan 21 by Niroj 142 views
+1 vote
1 answer

What is css box module?

Hey, All the element present in html follows ...READ MORE

answered Jan 20 in Web Development by Niroj
• 68,780 points

edited Jan 21 by Niroj 139 views
0 votes
1 answer

Explain the difference between visibility:hidden; and display:none?

hii, visibility:hidden; and display:none are totally different used ...READ MORE

answered Jan 20 in Web Development by Niroj
• 68,780 points
9,604 views
+1 vote
1 answer

How to access the Angularjs scope of a particular html element from our console?

Hello, You should follow the below steps:-- 1.Compile and ...READ MORE

answered Jan 21 in Web Development by Niroj
• 68,780 points

edited Jan 21 by Niroj 101 views
0 votes
1 answer

What is the “hasClass” function with plain JavaScript?

Hello @Kartik, Simply use classList.contains(): if (document.body.classList.contains('thatClass')) { ...READ MORE

answered Sep 2 in Java-Script by Niroj
• 68,780 points
54 views
0 votes
1 answer

What is an appropriate content-type header for JavaScript files?

Hello @kartik, JS has two registered MIME types:  The ...READ MORE

answered Jul 7 in Java-Script by Niroj
• 68,780 points
70 views