Asynchronous Programming - Reading Assignment

  1. Synchronous Functions are linear and are only able to be executed after the previous has been completed, Asynchronous functions are able to run and be set aside while other functions are performed, and called back later.

  2. Callback Hell refers to multiple levels and sublevels of Asynchronous Functions.

3 .In the browser, a common pattern to deal with excessive callbacks is to use promises. jQuery ships with a simple built-in promise library that enables us to chain callbacks and deal with errors.

1 Like

Wsup Fam
Please I am stuck
I tried doing the dynamic list(user adds element) assignment and couldn’t get it right on my own and afterwards, I copied @Ivan exact code word for word but still didn’t work. Meanwhile it worked when @Ivan executed his. Mine kept saying ā€œappendTo is not a function ā€œ . I am totally confused

1:Synchronous functions finish their execution one by one and Asynchronous functions can execute at the same parallel time.

2:Callback Hell is when you call a function that receives an endless amount of functions from it.

3: Avoiding Callback Hell can be done by doing {Promises, Async / await, and futures}

1 Like

1 Synchronous functions act in a written order / Asynchronous functions (callback functions) acts when they are ā€œcalled backā€ in numerous random ways

2 Weird structure of callbacks hard to read and make out of

3 Technics like Promises and Async/Await

1 Like
  1. What is the difference between synchronous and asynchronous functions?
    Synchronous function occupy Javes’ full attention and asynchronous ones works when they are called back
  2. What is callback hell?
    Calbacks which refers to multpile levels/sublevels
  3. Which technique can help us solve callback hell?
    Promises can be used
1 Like
  1. What is the difference between synchronous and asynchronous functions?
    Synchronous functions will lock up the browser until the code is executed, while asynchronous functions will not lock up the browser while it’s code is executing.

  2. What is callback hell?
    Callback hell is degree of complexity created by nested in a whole bunch of functions which in synchronous functions will completely lock up the browser/processing power.

  3. Which technique can help us solve callback hell?
    techniques of meteors and fibers.

1 Like

1.Synchronous way: It waits for each operation to complete, after that only it executes the next operation. … Asynchronous way: It never waits for each operation to complete, rather it executes all operations in the first GO only. The result of each operation will be handled once the result is available.
2. Callback hellis a phenomenon that afflicts a* JavaScript developer when he tries to execute multiple asynchronous operations one after the other. By nesting callbacks in such a way, we easily end up with error-prone
3. by event queue and promises

1 Like
  1. What is the difference between synchronous and asynchronous functions?
  • Synchronous only one section of the code is running at any given time causing delays.
    -Asynchronous is able to perform more than one functions of code at the same time enabling multitasking.
  1. What is callback hell?

-too many callbacks inside of other callbacks, code becomes messy to read and unclear sometimes.

  1. Which technique can help us solve callback hell?
  • the use of promises and being able to chain callbacks
1 Like
  1. A synchronous task implies that separate synchronous tasks are dependent on each other to complete so that they can all complete. Asynchronous implies without synchronicity and that the completion of one task is independent of the completion of another task.

  2. Callback Hell is a long nesting of asynchronous callback functions that can get very complicated.

  3. Promises are used to solve this problem, by taking an asynchronous function and creating a synchronous styled equivalent with synchronous control flow.

1 Like

Q: What is the difference between synchronous and asynchronous functions?

A: JS cannot handle multiple tasks at the same time so it can will handle it one by one. If you give to functions JS will handle the first one and after the first finishes will start handling the second one. This is called synchronous. Synchronous functions are not a big deal nowadays because of the speed of the computers we have. On the other hand, asynchronous functions are initiated and put aside for another day while JS does its every day tasks.

Q: What is callback hell?

A: When complex or even simple operations and functions require a lot of levels or sublevels.

Q: Which technique can help us solve callback hell?

A: Promises are used to solve the callback hell problem. Libraries can help us with errors and promises. Some of the libraries are JQuery, AngularJS, React.

1 Like

Please paste your code here so that we can debug your code and help you out. :smile:

  1. What is the difference between synchronous and asynchronous functions?
    Whereas a synchronous task will occupy Javes continuously until its completion, an asynchronous task can be initiated and then put aside until a later date while our valet gets started on the next task on his to-do list.

  2. What is callback hell?

Callback hell is when there is to many call backs, to many nested functions to be executed.

  1. Which technique can help us solve callback hell?
    By utilizing the Promise pattern to wrap function calls in a way that allows them to be chained in a much more readable manner than with standard callbacks. Promises in JavaScript allow for the developer to provide a callback function for branching execution: do this function if the operation results in success, and do this one if it fails. This is very powerful.
1 Like
  1. What is the difference between synchronous and asynchronous functions?
    -Sync functions will fully occupy the browser until it is complete, while Async functions will defer to the event loop to strategically handle more than one task intermittently.
  2. What is callback hell?
    -The multiplicity of nested functions that are required.
  3. Which technique can help us solve callback hell?
    -Promises, or Fibers
1 Like
  1. The difference between synchronous and asynchronous is the manner of execution. Synchronous waits for each operation to complete, after that only it executes the next operation. Asynchronous never waits for each operation to complete, rather it executes all operations in the first GO only. The result of each operation will be handled once the result is available.

  2. Callback hell is a phenomenon that afflicts a JavaScript developer when he tries to execute multiple asynchronous operations one after the other. By nesting callbacks in such a way, we easily end up with error-prone, hard to read, and hard to maintain code.

  3. There are four solutions to callback hell:
    a) Write comments
    b) Split functions into smaller functions
    c) Using Promises
    d) Using Async/await

1 Like
  1. Synchronus functions appear one after the other and do not allow the following function to execute until the previous has finished. Asynchronus functions will permit other functions to execute before it has completed all the tasks.

  2. Callback hell is when numerous asynchronous functions are idle because they’re waiting for other nested functions to complete the execution and thus halting the entire process.

  3. Promises can be used. It allows other tasks to complete up until the point it has the necessary amount of resources to continue.

1 Like
  1. Synchronous task will occupy Javes continuously until its completion, as asynchronous usually takes the form of Ajax this task can be initiated and then put aside until a later date while our valet gets started on the next task on his to-do list.

  2. Callback hell is requiring three levels of nested functions: the main trackUser, one looking up the user in the database, and one for inserting a new record.

  3. The technic to solve a callback hell is to use promises in order to deal with excessive callbacks, jQuery ships with a simple built-in promise library that enables us to chain callbacks and deal with errors.

1 Like
  1. What is the difference between synchronous and asynchronous functions?

Synchronous functions require waiting for the result to be finished before moving onto the next section of code. So only one section of code can be run at a time.
Asynchronous functions can be initialised and left to complete whilst starting the next section of code. This may be required in circumstances such as querying third party databases or API calls. The result of the function will be returned when it’s ready.

  1. What is callback hell?
    Callback hell is when you have nested functions which becomes increasingly difficult to keep track of

  2. Which technique can help us solve callback hell?
    Using Promises. jQuery comes with a built in Promises library that enables us to chain callbacks and deal with errors.

1 Like
  1. Synchronous code is executed in sequence and each statement waits for the previous statement to finish before executing. Asynchronous code doesn’t have to wait and the program can continue to run. We do this to keep the site responsive, reducing waiting times for the users.

  2. It is something that happens to JavaScript developers when they try to execute multiple asynchronous operations one after the other. If callbacks are nested this way, we will end up with errors and a hard to read code.

  3. Comment writing is a good way to prevent callback hell. Also to split functions into smaller functions, using promises or using async/await.
    So by maintaining a better separation of codes, we can reduce code clutter by declaring a callback function beforehand and call it later.

1 Like

1 Synchronous means that only one section of code is running at a certain time. Asynchronous means that it is able to perform multiple functions of code at the same time, basically allowing for multitasking.
2 Callback hell is when there are too many callbacks within other callbacks which makes the code messy and unclear to read.
3 Using promises and event queues

1 Like
  1. Synchronous functions in JavaScript can only take care of one task at a time (single-threaded environment), so only one section of code can be running at any one time.
    When we need more time (for example query third party servers for data or make API calls), Asynchronous functions can be initiated and put aside until a later date while our js code keeps running its tasks.

  2. Callback hell is when we have complex operations, and they require many levels and sub-levels of nested functions to execute, making it look not ideal.

  3. In the browser, a common pattern to deal with excessive callbacks is to use promises, that enable us to chain callbacks and deal with errors.
    jQuery ships with a simple built-in promise library, but in Node.js we can use a different approach. By extending the runtime, we can abstract away the asynchronicity and write code that looks sychronous.

1 Like