“Promise.Resolve” Respostas de código

Promise.Resolve

Promise.resolve(value);

// Using the static Promise.resolve method
Promise.resolve('Success').then(function(value) {
  console.log(value); // "Success"
}, function(value) {
  // not called
});

// Resolving an array
const p = Promise.resolve([1,2,3]);
p.then(function(v) {
  console.log(v[0]); // 1
});

// Resolving thenables and throwing Errors
const p2 = Promise.resolve(thenable);
p2.then(function(v) {
  // not called
}, function(e) {
  console.error(e); // TypeError: Throwing
});
web-noob master

O que é promessa em JavaScript

Promises make async javascript easier as they are easy to use and write than callbacks. Basically , promise is just an object , that gives us either success of async opertion or failue of async operations
Odd Ox

Resolução imediata da promessa

  Promise.resolve().then(() => {
    console.log('resolved');
  });
  console.log('end');

// end
// resolve
Mysterious Monkey

Procure respostas de código populares por idioma

Procurar outros idiomas de código