• js简单语法,循环


    <!DOCTYPE html>
    <html lang="en">
    <head>
        <meta charset="UTF-8">
        <title>js grammar</title>
    </head>
    <body>
           
        <script>
            //1.js语法
    
          /*  //https://www.cnblogs.com/yuanchenqi/articles/5980312.html
            // <script src="hello.js"> 引入方式
            var a = 1;  //声明变量时不用声明变量类型. 全都使用var关键字
            var b = 2 ,c = "cc"; //一行可以申明多个变量,且不用是同类型
            alert(a / b);
            alert(b / a);
            alert(c)
    
            function fun() {
                var va = "this is va";
                //alert(va)
                document.write(va)
               // console.log(va)
            }
            fun()
            */
            // 2.js数据类型
    
            /*var a = 2;
            var b = false;
            var c = 2.1;
            var d = NaN;
            var e = undefined;
            var f = null;
            var obj = new Object();
    
            console.log(typeof(a));
            console.log(typeof(b));
            console.log(typeof(c));
            console.log(typeof(d));
            console.log(typeof(e));
            console.log(typeof(f));
            console.log(typeof(obj));
    
            var aa = "abc"+12;
            alert(aa) ; // abc12
            //在js中false,ture分别代表0,1
            var bb = 1+false;
            alert(bb);
    
            var cc = 2 + true;
            alert(cc);*/
    
    /*        alert("hello"+true);
    
            alert(parseInt(3.14))
            alert(parseFloat("33.21"))*/
    
            // var a = 1;
            // alert(a++); //先赋值后加减 a = a+1   a= 1  所以a++获取的是a的值之后a=2
            // alert(a);  //2
            // alert(++a);  //3
            // alert(--a);  //2
            // alert(a--); //2
            // alert(a);  //1
    
           // alert(null==undefined); true
            //alert(false==0); true
            //alert(true ==1); true
            //alert(true == 2);  false
            //alert(undefined == 0); false
            //alert(5=="5");  true
            //alert(5==="5"); false
            var a = 1;
            var num = 0;
            for(a;a<=100;a++){
                num += a;
            }
            alert(num);
    
    
    
            a = {"aa":"bb","cc":"dd"}
            for (var i in a) {
                console.log(i);
                console.log(a[i]);
            }
    
    
             b = ["a","b","c","d"];
            for (var i in b){
                console.log(i);
                console.log(b[i]);
            }
    
            var a;
            switch (5){
                case 1: a = "aa"; break;
                case 2: a = "bb"; break;
                case 3: a = "cc"; break;
                default: a = "dd"; break;
            }
            alert(a)
    
            var c = 1;
            var counts = 0;
            while (c <=100){
                counts += c;
                c+=1;
            }
            alert(counts)
    
    
    
        </script>
    </body>
    </html>
  • 相关阅读:
    Java中的4种代码块
    Java enum(枚举)的用法详解(转)
    Java 可变参数列表
    SQL Server 查询处理中的各个阶段(SQL执行顺序)
    SQL Server 数据查询 整理
    MYSQL常用命令
    SQL的主键和外键约束(转)
    Servlet工作原理(转)
    servlet、genericservlet、httpservlet之间的区别(转)
    关于MyEcplise中常见的问题和解决方案
  • 原文地址:https://www.cnblogs.com/TKOPython/p/12813791.html
Copyright © 2020-2023  润新知