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 对象。
Me discréditer résister, peut supporter beaucoup de compliments!
浙公网安备 33010602011771号