1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26
| function test(a) {
if (a === undefined) {
alert("totalement undefined");
} else if (a == undefined) {
alert("vu comme undefined");
} else {
alert("pas undefined");
}
if (a === null) {
alert("totalement null");
} else if (a == null) {
alert("vu comme null");
} else {
alert("pas null");
}
if (a) {
alert(a);
} else {
alert("pas a");
}
}
test("valeur"); // test avec valeur
test(); // test sans valeur
test(null); // test avec valeur null
test(undefined); // test avec valeur undefined |