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ả đoạn js code sau là gì? Hãy giải thích tại sao?

senior

Trong JavaScript hàm map có thể lặp qua các thuộc tính của một đối tượng không?

middle

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

Bình luận

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

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