JavaScript có 7 kiểu dữ liệu nguyên thủy (primitive types):
1. string
2. number
3. boolean
4. null
5. undefined
6. symbol
7. bigint
Đặc điểm: Primitive type được copy theo giá trị (pass by value).
Ví dụ:
let a = 5;
let b = a;
b = 10;
console.log(a); // 5a vẫn là 5 vì b chỉ là một bản sao.
Khác với object và array (được copy theo tham chiếu - pass by reference).
Mẹo nhớ: typeof null trả về "object" là một lỗi lịch sử (historical bug) của JavaScript và không bao giờ được sửa để tránh hỏng các hệ thống cũ.
JavaScript has 7 primitive types:
- string
- number
- boolean
- null
- undefined
- symbol
- bigint
Primitives are copied by value.
Example: let a = 5; let b = a; b = 10; means a is still 5.
This is different from objects and arrays, which are copied by reference.
Memory tip: typeof null returning "object" is a historical bug.