js简单语法,循环

2021-03-14 02:35

阅读:339

标签:nan   使用   blog   语法   com   false   body   获取   tle   

DOCTYPE html>
html lang="en">
head>
    meta charset="UTF-8">
    title>js grammartitle>
head>
body>
       
    script>
        //1.js语法

      /*  //https://www.cnblogs.com/yuanchenqi/articles/5980312.html
        // */
        // 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;a100;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>

 

js简单语法,循环

标签:nan   使用   blog   语法   com   false   body   获取   tle   

原文地址:https://www.cnblogs.com/TKOPython/p/12813791.html


评论


亲,登录后才可以留言!