DEV Community

Mathu varshtih
Mathu varshtih

Posted on

Closure and Async/Awaits

  1. Closure: A closure is when an inner function remembers and can access variables from its outer function, even after the outer function has finished executing.

  2. Async/Await: async makes a function return a Promise, while await pauses execution inside that async function until a Promise settles, allowing asynchronous operations to be handled more easily.

Top comments (1)

Collapse
 
jonrandy profile image
Jon Randy 🎖️ •

Closures are formed EVERY time ANY function is formed - nested or otherwise. Every function retains access to the variables in its outer scope.