JavaScript string对象 + 九九乘法表

来源:互联网 发布:unity3d 海水的实现 编辑:程序博客网 时间:2024/06/06 02:31

 <script>

        var str = "hello Word!";

        var st = "Javascript";

    document.write(str.blink()+"<br/>");//blink() 方法用于显示闪动的字符串。Firefox

    document.write(str.anchor("myanchor") + "<br/>");

    document.write(str.big() + "<br/>");//big() 方法用于把字符串显示为大号字体。

    document.write(str.bold() + "<br/>");//使用粗体显示字符串。

    document.write(str.charAt(4) + "<br/>");//返回在指定位置的字符。

    document.write(str.charCodeAt(4) + "<br/>");//返回在指定的位置的字符的 Unicode 编码。

    document.write(str.concat(st) + "<br/>");//连接字符串

    document.write(str.fixed(st) + "<br/>");//以打字机文本显示字符串。

    document.write(str.fontcolor("purple") + "<br/>");//使用指定的颜色来显示字符串。

    document.write(str.fontsize(20).fontcolor("red").blink() + "<br/>");//使用指定的尺寸来显示字符串,颜色,闪动

    document.write(String.fromCharCode(72, 69, 76, 76, 79) + "<br/>");//根据 Unicode 来输出 "HELLO"

    document.write("<br />");

    document.write(String.fromCharCode(65, 66, 67) + "<br/>");//根据 Unicode 来输出 "ABC":

    document.write(String.fromCharCode(68) + "<br/>");//根据 Unicode 来输出"D"

    document.write(st.italics() + "<br/>");//斜体

    document.write(st.indexOf("a") + "<br/>");//查找字符串索引

    document.write(st.lastIndexOf("a") + "<br/>");//查找最后一个字符串索引

    alert(Math.abs(-100));//.abs()获取绝对值

    alert(Math.ceil(5.1));//返回最大整数,进1

    alert(Math.floor(5.9));//返回最小值,直接舍去小数,取整

    alert(Math.max(12, 23, 34));//返回最大值,参数至少两个

    alert(Math.min(12, 23, 34));//返回最小值,参数至少两个

    alert(Math.random());//随机数,返回0-1之间的一串小数

    alert(Math.round(12.5));//四舍五入    

 

 

 

99乘法表

    </script>

    <script>

        for(var i=1;i<=9;i++)

        {

            

            for(var a=1;a<=i;a++)

            {

                var r = i * a;

                document.write(i+"*"+a+"="+r+" ");

                

            }

            document.write("<br/>");

        }

    </script>

 


0 0
原创粉丝点击