if传入什么参数会进入里面

<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
</head>

<body>

</body>
<script>
    if (NaN) {
        alert("NaN进入了")
    } //NaN 不会进入
    if (null) {
        alert("null进入了")
    } //null 不会进入
    if ("null") {
        alert("字符null会进入")
    } //字符null会进入
    if (0) {
        alert("0会进入")
    } //0不会进入
    if (undefined) {
        alert("undefined会进入")
    } //undefined 不会进入
    if ("") {
        alert("空会进入")
    } //空不会进入
    if (123) {
        alert("数字会进入")
    } //数字会进入
    if (xx) {
        alert("没定义的变量会进入");
    } //会报错,xx is not defined
</script>

</html>

 

posted @ 2022-01-26 11:06  林逸夫  阅读(50)  评论(0)    收藏  举报