Kiểu null
null trong JavaScript là giá trị biểu thị không có giá trị.
null literal
null literal trong JavaScript là null.
tsconstx = null;
tsconstx = null;
Type annotation của null
Để type annotation cho null trong TypeScript, sử dụng null.
tsconstx : null = null;
tsconstx : null = null;
Lưu ý về toán tử typeof
JavaScript có toán tử typeof để kiểm tra type của giá trị. Cần lưu ý khi dùng typeof với null sẽ trả về "object".
tsconsole .log (typeof null);
tsconsole .log (typeof null);
Chi tiết về toán tử typeof xem tại phần "Toán tử typeof".
📄️ Toán tử typeof
Toán tử typeof của JavaScript cho phép kiểm tra kiểu của giá trị.