zoukankan      html  css  js  c++  java
  • JavaScript if 语句星期的判断

    <head>
        <meta charset="UTF-8">
        <title>星期的判断</title>
    </head>
    <body>
        <script>
            var dayOfWeek = 4;
            //if 语句的条件表达式只能为布尔型(可能存在数据类型自动转换)
            //switch语句的表达式为任意数据类型(布尔型除外)
            // if语句每次执行时都将对变量进行取值操作;而switch只进行一次取值
            //wsitch语句进行的是全等运算
            if (dayOfWeek == 0) {
                document.write('星期天')
            } else
            if (dayOfWeek == 1) {
                document.write('星期一')
            } else if (dayOfWeek == 2) {
                document.write('星期二')
            } else
            if (dayOfWeek == 3) {
                document.write('星期三')
            } else
            if (dayOfWeek == 4) {
                document.write('星期四')
            } else
            if (dayOfWeek == 5) {
                document.write('星期五')
            } else
            if (dayOfWeek == 6) {
                document.write('星期六')
            };
            switch (dayOfWeek) {
                case 0:
                    document.write('星期天')
                    break;
                case 1:
                    document.write('星期一')
                    break;
                case 2:
                    document.write('星期二')
                    break;
                case 3:
                    document.write('星期三')
                    break;
                case 4:
                    document.write('星期四')
                    break;
                case 5:
                    document.write('星期五')
                    break;
                case 6:
                    document.write('星期六')
                    break;
     
            }
        </script>
    </body>
    </html>
  • 相关阅读:
    gateone DSM 8271
    手机
    epub- https://www.taoshudang.com/
    [outlook] [vba] Highlight text in body of incoming emails
    HDMI ARC功能详解及应用介绍
    蓝光播放机
    surfingkeys
    亿格瑞A5-hdmi故障了
    解决VS无法连接到已配置的开发web服务器或者部署在IIS上的web服务打不开的问题
    解决远程连接mysql很慢的方法
  • 原文地址:https://www.cnblogs.com/001yjk/p/10610181.html
Copyright © 2011-2022 走看看