zoukankan      html  css  js  c++  java
  • zepto方法

    1、$.inArray

    $.inArray v1.0+

    $.inArray(element, array, [fromIndex]) ⇒ number

    搜索数组中指定值并返回它的索引(如果没有找到则返回-1)。

    [fromIndex] 参数可选,表示从哪个索引值开始向后查找。

    $.inArray("abc",["bcd","abc","edf","aaa"]);
              //=>1
    
              $.inArray("abc",["bcd","abc","edf","aaa"],1);
              //=>1
    
              $.inArray("abc",["bcd","abc","edf","aaa"],2);
              //=>-1

    2、$.isArray

    $.isArray(object) ⇒ boolean

    如果object是array,则返回ture。

    3、$.map

    $.map(collection, function(item, index){ ... }) ⇒ collection

    通过遍历集合中的元素,通过函数返回一个新的数组,null and undefined 将被过滤掉。

    $.map([1,2,3,4,5],function(item,index){
            if(item>1){return item*item;}
    }); 
    // =>[4, 9, 16, 25]
    
    $.map({"yao":1,"tai":2,"yang":3},function(item,index){
        if(item>1){return item*item;}
    }); 
    // =>[4, 9]

    3、$.parseJSON v1.0+

    $.parseJSON(string) ⇒ object

    类似本地JSON.parse 方法,接受一个标准格式的 JSON 字符串,并返回解析后的 JavaScript 对象。

  • 相关阅读:
    image对象
    Frame/IFrame 对象
    Form 对象
    JavaScript 对象 实例
    button对象
    正则介绍以及多种使用方法
    js /jquery停止事件冒泡和阻止浏览器默认事件
    一些兼容性的知识
    面试题总结
    事件
  • 原文地址:https://www.cnblogs.com/theWayToAce/p/7018908.html
Copyright © 2011-2022 走看看