1598597671
JavaScript Promises, callback and async await
understanding javascript callback, writing promises and async-await
► 💻👨🏫📕 Subscribe ► https://www.youtube.com/user/vibbbbbb…
#javascript #programming
1619272838
Explained in detail about
Dont miss to watch the video & ask your questions or doubts in comments
#javascript #async #await
1598637660
The async and await is keywords to perform the promise-based asynchronous operation. In this article, we are going to learn how to use async/await in JavaScript.
It is mandatory to define the async
keyword before any function that turns your normal function to async function. Let’s start to learn it through a very basic example.
function sayHello() {
return 'Hello World!';
}
sayHello(); // Hello World!
Copy
async function sayHello() {
return 'Hello World!';
}
sayHello(); // [object Promise] { ... }
Copy
We could explicitly return a promise with Promise.resolve() like:
async function sayHello() {
return Promise.resolve('Hello World!');
}
async function sayHello() {
return 'Hello World!';
}
let greeting = sayHello();
greeting.then((value) => console.log(value)); // Hello World!
Copy
or you can try this:
async function sayHello() {
return 'Hello World!';
}
sayHello().then((value) => console.log(value) ); // Hello World!
#javascript #async #await
1600929360
We all know the importance of promises in our life. We even have a special day dedicated to it :) But how well do we know the importance of promises in JavaScript? Well if you don’t know it yet, it’s a great time to know it because they are becoming more and more popular. So what are promises? Let’s try to understand it through an analogy.
Suppose you are a top class rapper and you haven’t released an album for a while and fans are asking for it day and night. So what you do is that you “promise” them that whenever it will be out, all of them would be notified. To get this done you give your fans a list. They can fill in their email addresses, so that when the album becomes available, all the subscribers instantly receive it. And even if something goes wrong, say a pandemic, so that you can’t release the album, they will still be notified.
Now everyone is happy: You, because the people don’t crowd you anymore, and fans, because they won’t miss any news on the album.
This is a real-life analogy for things we often have in programming:
JavaScript promises are much more complex than a simple subscription list: they have additional features and limitations. But it’s fine to begin with.
#async #promises #javascript #development #await
1600874280
Javascript async-await feature is used to deal with asynchronous code in javascript. The async-await is a just new technique to write async code in a sync function manner. You can write it as a simple synchronous function. That makes it very popular and understandable. Node.js is now supporting async-await out of the box.
Async-await is a new way to write asynchronous code. Previous options for asynchronous code are callbacks and promises. Async/await built on top of promises. It cannot be used with plain callbacks or node callbacks.
You can read the following tutorials if you do not know anything about Javascript callbacks and promises.
Promises In ES6
Callback in Javascript
#javascript #node.js #async/await
1622207074
Who invented JavaScript, how it works, as we have given information about Programming language in our previous article ( What is PHP ), but today we will talk about what is JavaScript, why JavaScript is used The Answers to all such questions and much other information about JavaScript, you are going to get here today. Hope this information will work for you.
JavaScript language was invented by Brendan Eich in 1995. JavaScript is inspired by Java Programming Language. The first name of JavaScript was Mocha which was named by Marc Andreessen, Marc Andreessen is the founder of Netscape and in the same year Mocha was renamed LiveScript, and later in December 1995, it was renamed JavaScript which is still in trend.
JavaScript is a client-side scripting language used with HTML (Hypertext Markup Language). JavaScript is an Interpreted / Oriented language called JS in programming language JavaScript code can be run on any normal web browser. To run the code of JavaScript, we have to enable JavaScript of Web Browser. But some web browsers already have JavaScript enabled.
Today almost all websites are using it as web technology, mind is that there is maximum scope in JavaScript in the coming time, so if you want to become a programmer, then you can be very beneficial to learn JavaScript.
In JavaScript, ‘document.write‘ is used to represent a string on a browser.
<script type="text/javascript">
document.write("Hello World!");
</script>
<script type="text/javascript">
//single line comment
/* document.write("Hello"); */
</script>
#javascript #javascript code #javascript hello world #what is javascript #who invented javascript