Java Coaching Centre

Java Coaching Centre

Share

20/08/2021

Promise can be access in below way:

Syntax:then(function(result){
//This function is called when resolve() is called.
}, function(error){
//This function is called when reject() is called.
})

In this way of accessing the promise, .then() is invoked when a promise is either resolved or rejected. then() method takes two functions as parameters. First function is executed if promise is resolved and a result is received. Second function is executed if promise is rejected and an error is received.

Promise Resolved Example ::
var promise = new Promise(function(resolve, reject) {
resolve("Java Learning Centre");
})

promise
.then(function(successMessage) {
//This function is invoked now.
console.log(successMessage);
}, function(errorMessage) {
console.log(errorMessage);
})

Promise Rejected Example ::
var promise = new Promise(function(resolve, reject) {
reject("Promise Rejected here")
})

promise
.then(function(successMessage) {
console.log(successMessage);
}, function(errorMessage) {
//This error handler function is invoked.
console.log(errorMessage);
})

20/08/2021

Promises are used to handle asynchronous operations in JavaScript. Promises are the ideal choice for handling asynchronous operations in the simplest manner. They can handle multiple asynchronous operations easily and provide better error handling.

A promise can be created in fallowing way:
var promise = new Promise(function(resolve, reject){
//do something
});

Note:
1. Promises are used for asynchronous handling of events.
2. Promises are used to handle asynchronous http requests.

16/08/2021

Infinite loops run infinitely without break condition.
Some examples of Infinite loops are:

1. Using for loop :

for (;;)
{
// Business logic
// Any break logic
}

2. Using while loop:

while(true){
// Business logic
// Any break logic
}

3.Using do-while loop:

do{
// Business logic
// Any break logic
}while(true);

16/08/2021

What is promise in javascript?

14/08/2021

Angular Framework has below key components:

1. Component: These are the basic building blocks of
angular application to control HTML views.

2. Modules: An angular module is set of angular basic
building blocks like component, directives, services
etc. An application is divided into logical pieces and
each piece of code is called as "module" which
perform a single task.

3. Templates: This represent the views of an Angular application.
Services: It is used to create components which can
be shared across the entire application.
4. Metadata: This can be used to add more data to an Angular
class.

14/08/2021

Angular Architecture

Want your business to be the top-listed Computer & Electronics Service in Bangalore?
Click here to claim your Sponsored Listing.

Telephone

Website

Address


Nagappa Street, Palace Guttahalli, Sheshadripuram, Near Malleswaram Circle And Fortis Hospital
Bangalore
560092