From 0e8de321fdb07deeb304e113b308d27350e333fc Mon Sep 17 00:00:00 2001 From: imrozkhan205 Date: Sat, 14 Sep 2024 18:44:16 +0530 Subject: [PATCH] async in js --- Async/async.md | 20 ++++++++++++++++++++ Async/asynchronous.md | 25 +++++++++++++++++++++++++ Async/callbacks.md | 31 +++++++++++++++++++++++++++++++ Async/promises.md | 18 ++++++++++++++++++ javascript-docs | 1 + 5 files changed, 95 insertions(+) create mode 100644 Async/async.md create mode 100644 Async/asynchronous.md create mode 100644 Async/callbacks.md create mode 100644 Async/promises.md create mode 160000 javascript-docs diff --git a/Async/async.md b/Async/async.md new file mode 100644 index 00000000..f7764133 --- /dev/null +++ b/Async/async.md @@ -0,0 +1,20 @@ + + + +

JavaScript async / await

+

+ + + + + diff --git a/Async/asynchronous.md b/Async/asynchronous.md new file mode 100644 index 00000000..52a029c7 --- /dev/null +++ b/Async/asynchronous.md @@ -0,0 +1,25 @@ + + + + +

JavaScript Functions

+

Callback Functions

+ +

The result of the calculation is:

+

+ + + + + diff --git a/Async/callbacks.md b/Async/callbacks.md new file mode 100644 index 00000000..9096cbd7 --- /dev/null +++ b/Async/callbacks.md @@ -0,0 +1,31 @@ + + + + +

JavaScript Functions

+

Function Sequence

+

JavaScript functions are executed in the sequence they are called.

+ +

+ + + + + + + diff --git a/Async/promises.md b/Async/promises.md new file mode 100644 index 00000000..94cba13c --- /dev/null +++ b/Async/promises.md @@ -0,0 +1,18 @@ +let myPromise = new Promise(function(myResolve, myReject) { +// "Producing Code" (May take some time) + + myResolve(); // when successful + myReject(); // when error +}); + +// "Consuming Code" (Must wait for a fulfilled Promise) +myPromise.then( + function(value) { /* code if successful */ }, + function(error) { /* code if some error */ } +); + +When the producing code obtains the result, it should call one of the two callbacks: + +When Call +Success myResolve(result value) +Error myReject(error object) \ No newline at end of file diff --git a/javascript-docs b/javascript-docs new file mode 160000 index 00000000..09593f9c --- /dev/null +++ b/javascript-docs @@ -0,0 +1 @@ +Subproject commit 09593f9ca9e396e383d1cdc49cf641ca9f0e9446