ชนิดข้อมูลพื้นฐาน

ห้าชนิดที่เจอบ่อยตอนเริ่ม

number — ตัวเลข เช่น 42, 3.14

string — ข้อความในเครื่องหมายคำพูด "สวัสดี" หรือ 'สวัสดี'

booleantrue หรือ false

undefined — ประกาศแล้วแต่ยังไม่มีค่า

null — ตั้งใจว่า “ว่าง / ไม่มีค่า”

const age = 18;
const name = "Mim";
const isPass = true;
let nickname;
const emptyBox = null;

console.log(age, name, isPass);
console.log(nickname);
console.log(emptyBox);

ผลลัพธ์ที่คาดหวัง

18 Mim true
undefined
null