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

Explica este código JavaScript

Dificultad: Intermedio

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

const two = () => {
return ne…


This content originally appeared on DEV Community and was authored by Cristian Fernando

Explica este código JavaScript

Dificultad: Intermedio

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

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

const three = () => {
  return new Promise((resolve, reject) => {
    setTimeout(() => {
      reject("three")
    }, 10000)
  })
}

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

res()
  .then(x => console.log(x))
  .catch(err => console.log(err))
  • A. "["one", "three", "two"]" (después de 10s)
  • B. "one" (después de 5s)
  • C. "three" (después de 10s)
  • D. "two" (después de 2s)

Respuesta en el primer comentario.


This content originally appeared on DEV Community and was authored by Cristian Fernando


Print Share Comment Cite Upload Translate Updates
APA

Cristian Fernando | Sciencx (2023-03-15T11:22:00+00:00) Paracetamol.js💊| #204: Explica este código JavaScript. Retrieved from https://www.scien.cx/2023/03/15/paracetamol-js%f0%9f%92%8a-204-explica-este-codigo-javascript/

MLA
" » Paracetamol.js💊| #204: Explica este código JavaScript." Cristian Fernando | Sciencx - Wednesday March 15, 2023, https://www.scien.cx/2023/03/15/paracetamol-js%f0%9f%92%8a-204-explica-este-codigo-javascript/
HARVARD
Cristian Fernando | Sciencx Wednesday March 15, 2023 » Paracetamol.js💊| #204: Explica este código JavaScript., viewed ,<https://www.scien.cx/2023/03/15/paracetamol-js%f0%9f%92%8a-204-explica-este-codigo-javascript/>
VANCOUVER
Cristian Fernando | Sciencx - » Paracetamol.js💊| #204: Explica este código JavaScript. [Internet]. [Accessed ]. Available from: https://www.scien.cx/2023/03/15/paracetamol-js%f0%9f%92%8a-204-explica-este-codigo-javascript/
CHICAGO
" » Paracetamol.js💊| #204: Explica este código JavaScript." Cristian Fernando | Sciencx - Accessed . https://www.scien.cx/2023/03/15/paracetamol-js%f0%9f%92%8a-204-explica-este-codigo-javascript/
IEEE
" » Paracetamol.js💊| #204: Explica este código JavaScript." Cristian Fernando | Sciencx [Online]. Available: https://www.scien.cx/2023/03/15/paracetamol-js%f0%9f%92%8a-204-explica-este-codigo-javascript/. [Accessed: ]
rf:citation
» Paracetamol.js💊| #204: Explica este código JavaScript | Cristian Fernando | Sciencx | https://www.scien.cx/2023/03/15/paracetamol-js%f0%9f%92%8a-204-explica-este-codigo-javascript/ |

Please log in to upload a file.




There are no updates yet.
Click the Upload button above to add an update.

You must be logged in to translate posts. Please log in or register.