• JavaScript学习


    String对象

    更详细转:http://www.w3school.com.cn/jsref/jsref_obj_string.asp

     //--------------------------------------------------------
        // string对象属性:
        // length
        var x = [1,2,3,4,5,6]
        document.write(x.length)
        //6
    
        //--------------------------------------------------------
        // 方法:
    
        //string - anchor()方法(创建HTML锚标签)
        var x = "hello world!";
        document.write(x.anchor("myanchor"))
        //<a name="myanchor">Hello world!</a>
        
        //斜体
        document.write(x.italics())
        //粗体
        document.write(x.bold())
    
        //查询索引
        document.write(x.indexOf('l'))
        document.write(x.lastIndexOf('l'))
        2
        9
    
        //索引截取字符串
        document.write(x.substr(1,2));
        //le
        document.write(x.substring(1,2));
        // e
    
        //切片
        document.write(x.slice(1,2));
        document.write(x.slice(-2,-1));
        //e
        //d

    数组对象(array)

     // //数组
        // -join
        // -concat
        // -reverse
        // -sort
    
        // // -slice(1,2,3)
        // 位置1,索引位置
        // 位置2,需要删除的个数
        // 位置3,插入数据
    
        //进出栈(先入后出)
        // push 、 pop
    
        //(先入先出)
        //shift、unshift

    函数对象(function)

    <script>
        //创建函数
        function f(x) {
            console.log("this is " + x)
        }
        f('alex')
    
    
        //传入多个参数: argument == kwargs
        function f() {
            var sun = 0;
            for(var i =0;i<arguments.length;i++){
                sun += arguments[i];
            }
            return sun
        }
       console.log(f(1,2,3,4,56,7,8,9,0))
               
        // 匿名函数
        (function(name) {
                alert(name)
            })('alex')
    </script>

    windows对象

    windwos对象 方法
    
        //提示框
        window.alert("OK")
    
        //确认框,返回true false
        var re = window.confirm('this confirm');
        console.log(re)
        //true
    
        //弹出输入框,返回输入值或者None
        var re2 = window.prompt("this promt")
        console.log(re2)
    
        //打开新的页面
        open("http://www.baidu.com")
        close()
    
        //多长时间执行函数,1000 = 1s
        var f1 = setInterval(f1,3000);
    
        //取消以上操作
        function s2() {
            clearInterval(f1)
        }
  • 相关阅读:
    汉文博士 0.5.6.2345 修订版发布
    汉文博士 0.5.6 正式版发布
    汉文博士 0.5.5 正式版发布
    汉文博士新测试版发布(0.5.4.2228)
    海盗(Haidao)网店系统最新官方版
    ZipMarket数字内容/素材交易网站源码项目
    windows phone 8 使用页面传对象的方式 实现页面间的多值传递
    仿win8磁贴界面以及功能
    三角形状的点阵模糊效果iOS源码
    Coding iOS客户端应用源码
  • 原文地址:https://www.cnblogs.com/Anec/p/9828610.html
Copyright © 2020-2023  润新知