Câu hỏi phỏng vấn Javascript
Câu hỏi

Kết quả đoạn code javascript sau là gì? Hãy giải thích chi tiết?

Câu trả lời

javascript Copy
  const promise1 = Promise.resolve("First");
  const promise2 = Promise.resolve("Second");
  const promise3 = Promise.reject("Third");
  const promise4 = Promise.resolve("Fourth");

  const runPromises = async () => {
    const res1 = await Promise.all([promise1, promise2]);
    const res2 = await Promise.all([promise3, promise4]);
    return [res1, res2];
  };

  runPromises()
    .then((res) => console.log(res))
    .catch((err) => console.log(err));
  • A: [['First', 'Second'], ['Fourth']]
    ...
middle

middle

Gợi ý câu hỏi phỏng vấn

middle

Kết quả của đoạn code javascript sau là gì và giải thích tại sao?

middle

Đoạn code javascript sau output là gì? Hãy giải thích tại sao?

entry

Javascript có các kiểu dữ liệu nào? Bạn biết gì về chúng

Bình luận

Chưa có bình luận nào

Chưa có bình luận nào