js笔记3

<!DOCTYPE html>
<html lang="en">
<head >
    <meta charset="UTF-8">
    <title></title>
</head>
<body onload="startTime()">
<!--创建对象-->
<script>
    Student = new Object();
    //    Student.name="jaycee"
    //    Student.age="26"
    //    document.write("name="+Student.name+"\nage="+Student.age)
    //    Student={name:"jiangchao",age:"27"}
    //document.write("name="+Student.name+"\nage="+Student.age)

    function student(name, age) {
        this.name = name;
        this.age = age;

    }
    son = new student("zhao", 26)
//    document.write("name=" + son.name + "\nage=" + son.age)

    var str="hhha|sd0|_ji|ang|chao";
//    document.write("字符串长度为:"+str.length+"==="+str.indexOf('h'));
//    document.write(str.match("jiangchao"));
//    document.write((str.replace("jia","jian")).toUpperCase());
//   document.write((str.replace("jia","jian")).toUpperCase());
   var str2=str.split("|")
//document.write(str2[2])

  var date =new Date();
//document.write(date.getTime());


    //时钟
    function startTime(){
        var date =new Date();
        var hour =date.getHours();
        var minute=date.getMinutes();
        var second=date.getSeconds();
        minute=checkTime(minute);
        hour=checkTime(hour);
        second=checkTime(second);
        document.getElementById("showTime").innerHTML="现在时间"+hour+":"+minute+":"+second;
        time=setTimeout(function(){
            startTime()
        },1000)
    }
    function checkTime(i){
    if(i<10){
        i="0"+i;
    }
        return i;

    }


    var arr=["1111","2222"];
    var arr1=["3333","4444"];
//    document.write(arr.concat(arr1));


    var a=["9","1","7","0","8"]
    var b=["d","z","s","a","o"]
//    document.write(a.sort()+ b.sort());

    //升序降序
// document.write(a.sort(function (a,b){
//        return b-a
//    }))
    document.write(a.reverse());


    var xxx=["l","h","z","a"];
    xxx.push("DS");

    document.write("push");

</script>
<div id="showTime"></div>
</body>
</html>

猜你喜欢

转载自blog.csdn.net/u010111008/article/details/51931545
JS3
今日推荐