Skip to content

Commit 4235698

Browse files
committed
partial fix: explain-the-difference-between-synchronous-and-asynchronous-functions
1 parent 6bc474a commit 4235698

File tree

1 file changed

+2
-2
lines changed
  • questions/explain-the-difference-between-synchronous-and-asynchronous-functions

1 file changed

+2
-2
lines changed

questions/explain-the-difference-between-synchronous-and-asynchronous-functions/en-US.mdx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ title: Explain the difference between synchronous and asynchronous functions in
66

77
Synchronous functions are blocking while asynchronous functions are not. In synchronous functions, statements complete before the next statement is run. As a result, programs containing only synchronous code are evaluated exactly in order of the statements. The execution of the program is paused if one of the statements take a very long time.
88

9-
```js
9+
```js live
1010
function sum(a, b) {
1111
console.log('Inside sum function');
1212
return a + b;
@@ -70,7 +70,7 @@ Synchronous functions execute in a sequential order, one after the other. Each o
7070

7171
2. **Looping over large datasets**: Iterating over a large array or dataset synchronously can freeze the user interface or browser tab until the operation completes, leading to an unresponsive application.
7272

73-
```js
73+
```js live
7474
const largeArray = new Array(1_000_000).fill(0);
7575
// Blocks the main thread until the million operations are completed.
7676
const result = largeArray.map((num) => num * 2);

0 commit comments

Comments
 (0)