Câu hỏi

Kết quả đoạn code sau là gì?

  async function getData() {
    return await Promise.resolve("I made it!");
  }

  const data = getData();
  console.log(data);
  • A: "I made it!"
  • B: Promise {<resolved>: "I made it!"}
  • C: Promise {<pending>}
  • D: undefined

junior
Hide Answers detail

Đáp án: C

Một hàm async luôn luôn trả về một promise. await sẽ chờ cho tới k...

You need to login to view

Suggest other questions

Sự khác biệt của biến dùng var, letconst

See the answer detail

Sử dụng Promise trong JavaScript như thế nào?

See the answer detail

Đệ quy là gì?

See the answer detail

Kết quả đoạn code sau là gì?

function getAge() {
  "use strict";
  age = 21;
  console.log(age);
}

getAge();
  • A: 21
  • B: undefined
  • C: ReferenceError
  • D: TypeError
See the answer detail

Kết quả đoạn code sau là gì?

function checkAge(data) {
  if (data === { age: 18 }) {
    console.log("You are an adult!");
  } else if (data == { age: 18 }) {
    console.log("You are still an adult.");
  } else {
    console.log(`Hmm.. You don't have an age I guess`);
  }
}

checkAge({ age: 18 });
  • A: You are an adult!
  • B: You are still an adult.
  • C: Hmm.. You don't have an age I guess
See the answer detail