JS Coding Questions Logo
JS Coding Questions
#63💼 Interview💻 Code

What is callback in callback

Advertisement

728x90

You can nest one callback inside in another callback to execute the actions sequentially one by one. This is known as callbacks in callbacks. Beware, too many levels of nesting lead to Callback hell

javascript
1loadScript("/script1.js", function (script) {
2
3console.log("first script is loaded");
4
5loadScript("/script2.js", function (script) {
6  console.log("second script is loaded");
7
8  loadScript("/script3.js", function (script) {
9  console.log("third script is loaded");
10  // after all scripts are loaded
11  });
12});
13});

Advertisement

Responsive Ad
🎯 Practice NowRelated Challenge

JavaScript Coding Exercise 64

Test your knowledge with this interactive coding challenge.

Start Coding

Advertisement

728x90
63of476