Paracetamol.js💊| #208: Explica este código JavaScript

paracetamol.js|-#208:-explica-este-codigo-javascript

Explica este código JavaScript


Dificultad: Intermedio

const one = () => {
  return new Promise((resolve, reject) => {
    setTimeout(() => {
      resolve("one")
    },5000)
  })
}

const two = () => {
  return new Promise((resolve, reject) => {
    setTimeout(() => {
      reject(new Error("Error!"))
    }, 2000)
  })
}

const res = () => {
  return Promise.allSettled([one(), two()])
}

res()
  .then(x => console.log(x))
  .catch(err => console.log(err))
  • A.
[
  {status: "fulfilled", value: "one"},
  {status: "rejected", reason: "Error!"}
]

(después de 5s)

  • B.
[
  {status: "fulfilled", value: "one"},
  {status: "fulfilled", value: "two"}
]

(después de 5s)

  • C. Promise { }
  • D. Ninguna de las anteriores

Respuesta en el primer comentario.

Total
0
Shares
Leave a Reply

Your email address will not be published. Required fields are marked *

Previous Post
php-search-box-with-mysql-and-ajax-jquery

PHP Search Box with MYSQL and AJAX JQuery

Next Post
writing-a-multithreaded-image-dithering-program-with-rust-️

Writing a Multithreaded Image Dithering Program with Rust 🦀🖼️

Related Posts