zoukankan      html  css  js  c++  java
  • JS 内置对象

    什么是对象

    <!DOCTYPE html>
    <html>
    <head>
        <meta charset="utf-8" />
        <title>什么是对象</title>
    </head>
    <body>
        <script>
            //people = new Object();
            //people.name = "aaa";
            //people.age = "20";
            //document.write("name:" + people.name + ",age:" + people.age);
        </script>
    
        <script>
            function people(name, age) {
                this.name = name;
                this.age = age;
            }
            son = new people("son", 32);
            document.write("name: " + son.name + ",age: " + son.age);
        </script>
    </body>
    </html>

    2

    <!DOCTYPE html>
    <html>
    <head>
        <meta charset="utf-8" />
        <title>Date日期对象</title>
    </head>
    <body onload="startTime()">
        <script>
            function startTime() {
                var today = new Date();
                var h = today.getHours();
                var m = today.getMinutes();
                var s = today.getSeconds();
                m = checkTime(m);
                s = checkTime(s);
                document.getElementById("timeText").innerHTML = h + ":" + m + ":" + s;
                t = setTimeout(function () {
                    startTime();
                }, 500);
            }
    
            function checkTime(i) {
                if (i < 10) {
                    i = "0" + i;
                }
                return i;
            }
        </script>
        <div id="timeText"></div>
    </body>
    </html>

    3

    <!DOCTYPE html>
    <html>
    <head>
        <meta charset="utf-8" />
        <title>Array数组对象</title>
    </head>
    <body>
    
        <script>
            //var a = ["hello", "world"];
            //var b = ["iwen", "ime"];
            //var c = a.concat(b);
            //document.write(c);
            //var a = ["a", "c", "d", "t", "b", "e"];
            //var b = ["5", "2", "4", "3", "1", "6"];
            //document.write(a.sort());
            //document.write("<br/>");
            //document.write(b.sort());
            //document.write("<br/>");
            //document.write(a.sort(function (a, b) {
            //    return b - a;
            //}));
    
            var a = ["c", "b", "a"];
            document.write(a.reverse());
        </script>
    </body>
    </html>
  • 相关阅读:
    OC拨打电话
    oc唯一标时一部设备
    去掉UITableView多余的分割线
    UICollectionView的使用
    设置ulabel的行间距
    uitextfield
    iOS导航栏适配
    App Store 升级问题
    mac中使用终端生成RSA私钥和公钥文件
    js document
  • 原文地址:https://www.cnblogs.com/kikyoqiang/p/11223006.html
Copyright © 2011-2022 走看看