zoukankan      html  css  js  c++  java
  • 控制流程语句

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <script type="text/javascript">
    /*
    控制流程语句
    
        if语句
        
        格式:
            if(判断条件){
                符合条件执行的代码    
            }    
        
        if语句的特殊之处: 
            1. 在javascript中的if语句条件不单止可以写布尔表达式,还可以写任何的数据。
            
            number  非0为true, 0为false.
            string  内容不能空是true, 内容空的时候是false。
            undefined:false
            NaN:    false
        
        
        
        var workAge = 0;
        var str ="";
        var b;
        if(b){
            document.write("明天过来面试!!");
        }else{
            document.write("不要在投我们公司了,不要你!");    
        }
        
    
    选择语句: 
        switch语句
        
            switch(变量){
                case 值1:&nbsp;
                    
                    break;
                case 值2:
                    
                    break;
                case 值3:
                    
                    break;
                    
                .....
                    
                default:
                    
                    break;
                
            }
            
        特殊之处:
            1.     在javascript中case后面可以跟常量与变量还可以跟表达式。
            
            
    */
        
        
        var option = "A";
        
        var a = "A";
        var score =98;
        switch(option){
            case score>=90?"A":"B":
                document.write("java");
                break;
            case "B":
                document.write("ps");
            
            case "C":
                document.write("javascript");
                break;
            case "D":
                document.write("C++");
                break;
        }
    
    
    
    
    
    
    
    
    </script>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>无标题文档</title>
    </head>
    <body>
    
    
    </body>
    </html>
  • 相关阅读:
    初识Qgis
    特征向量与特征值及其应用
    练习 |委托方在每个月重复委案率
    Redis命令总结
    sharepoint2013 Restore-SPSite 报错,采用数据库还原
    MySql定期存档数据
    PostgreSQL的 fdw 跨库使用
    java&c# dec 加密,通用
    TypeScript
    CentOS挂载windows共享文件夹
  • 原文地址:https://www.cnblogs.com/themost/p/6915370.html
Copyright © 2011-2022 走看看