Dùng toán tử so sánh chặt === để kiểm tra null: if (variable === null).
Ví dụ
<html>
<head>
<title>Kiểm tra null trong JavaScript</title>
</head>
<body>
<script>
var a = 10;
if (a === null) {
document.write("Giá trị là null");
} else {
document.write("Giá trị KHÔNG phải null");
}
</script>
</body>
</html>