Câu hỏi
Kết quả đoạn code sau là gì?
let randomValue = { name: "Lydia" };
randomValue = 23;
if (!typeof randomValue === "string") {
console.log("It's not a string!");
} else {
console.log("Yay it's a string!");
}
- A:
It's not a string!
- B:
Yay it's a string!
- C:
TypeError
- D:
undefined
Đáp án: B
Điều kiện trong mệnh đề if
kiểm tra xem giá trị của !typeof randomValue
bằng với "string"
hay không. Phép to...