makeArray : 类数组转真数组

merge : 合并数组或转特殊json

使用例子(外部使用):

var aDiv = document.getElementsByTagName('div');
console.log($.makeArray(aDiv));  //[div,div,div]

var str = 'hello';
console.log($.makeArray(str)); //['hello']

var num = 123;
console.log($.makeArray(num)); //[123]

使用例子(内部使用):

var num = 123;
console.log($.makeArray(num, {length:0})); //{0:123,length:1}

var core_push = Array.prototype.push,

    ....................

jQuery.extend({

    ......................

    // results is for internal usage only
makeArray: function( arr, results ) {
var type,
ret = results || []; if ( arr != null ) {
// The window, strings (and functions) also have 'length'
// Tweaked logic slightly to handle Blackberry 4.7 RegExp issues #6930
type = jQuery.type( arr ); if ( arr.length == null || type === "string" || type === "function" || type === "regexp" || jQuery.isWindow( arr ) ) {
core_push.call( ret, arr );
} else {
jQuery.merge( ret, arr );
}
} return ret;
}, merge: function( first, second ) {
var l = second.length,
i = first.length,
j = 0; if ( typeof l === "number" ) {
for ( ; j < l; j++ ) {
first[ i++ ] = second[ j ];
} } else {
while ( second[j] !== undefined ) {
first[ i++ ] = second[ j++ ];
}
} first.length = i; return first;
}, ............... });

jquery工具方法makeArray/merge的更多相关文章

  1. Java程序猿的JavaScript学习笔记(9—— jQuery工具方法)

    计划按例如以下顺序完毕这篇笔记: Java程序猿的JavaScript学习笔记(1--理念) Java程序猿的JavaScript学习笔记(2--属性复制和继承) Java程序猿的JavaScript ...

  2. jQuery工具方法

    目录 常用工具方法 判断数据类型的方法 Ajax操作 $.ajax 简便写法 Ajax事件 返回值 JSONP 文件上传 参考链接 jQuery函数库提供了一个jQuery对象(简写为$),这个对象本 ...

  3. jQuery工具--$.each()和$.merge()

       jQuery.each(object, [callback])或者jQuery(object).each([callback]) 概述 通用遍历方法,可用于遍历对象和数组. 不同于遍历 jQue ...

  4. jquery工具方法总结

    $.extend 对象合并,支持深拷贝 $.each 相当于array.each或object.each,可以遍历数组和对象 $.grep 相当于array.filter $.map 相当于array ...

  5. jquery工具方法access详解

    access : 多功能值操作(内部) access方法可以使set/get方法在一个函数中体现.比如我们常用的css,attr都是调用了access方法. css的使用方法: $(selector) ...

  6. jquery工具方法proxy

    proxy : 改变this指向 使用方法1:function show(){ alert(this); }$.proxy(show,document)();  //document 使用方法2:fu ...

  7. jquery工具方法parseJSON

    error : 自定义错误 parseJSON : 字符串转json trim : 去除字符串头尾空字符 parseJSON方法先判断参数是否为字符串,否则返回空对象,再去除字符串头尾空字符,判断是否 ...

  8. jquery源码解析:jQuery工具方法when详解

    我们先来看when方法是如何使用的: var cb = $.when();   //when方法也是返回一个延迟对象,源码是return deferred.promise();返回的延迟对象不能修改状 ...

  9. jquery源码解析:jQuery工具方法Callbacks详解

    我们首先来讲下Callbacks是如何使用的:第一个例子 function a(){} function b(){} var cb = $.Callbacks(); cb.add(a); cb.add ...

随机推荐

  1. Sharepoint学习笔记—习题系列--70-576习题解析 -(Q21-Q24)

    Question 21 An application will be deployed in a SharePoint 2010 server farm that is managed by depa ...

  2. IOS常用第三方开源类库&组件

    1.AFNetworking AFNetworking 采用 NSURLConnection + NSOperation, 主要方便与服务端 API 进行数据交换, 操作简单, 功能强大, 现在许多人 ...

  3. umeng 渠道统计ios

    1. 使用前提:需要在工程中添加依赖框架:AdSupport.framework 和 Security.framework 2.在AppDelegate.m文件中的-(BOOL)application ...

  4. 微信公众号里打开链接下载APP

    嵌入这样的代码 <a href="http://a.app.qq.com/o/simple.jsp?pkgname=com.violationquery" target=&q ...

  5. 深入浅出-iOS程序性能优化 (转载)

    iOS应用是非常注重用户体验的,不光是要求界面设计合理美观,也要求各种UI的反应灵敏,我相信大家对那种一拖就卡卡卡的 TableView 应用没什么好印象. iOS应用是非常注重用户体验的,不光是要求 ...

  6. 免费开发者证书真机调试App ID失效问题:"Unable to add App ID because the '10' App ID limit in '7' days has been exceeded."解决方案(5月5号)

    免费开发者证书真机调试App ID失效问题:"Unable to add App ID because the '10' App ID limit in '7' days has been ...

  7. Eclipse中jsp、js文件编辑时,卡死现象解决汇总

    使用Eclipse编辑jsp.js文件时,经常出现卡死现象,在网上百度了N次,经过N次优化调整后,卡死现象逐步好转,具体那个方法起到作用,不太好讲.将所有用过的方法罗列如下: 1.取消验证 windo ...

  8. C#双色球——简单抽取中奖号码

    int[] ss = new int[6];            Random s = new Random();            Console.WriteLine("双色球随机: ...

  9. 对最近的RTP和H264学习进行总结整理-04.20

    虽然还是没有搞出来,但总感觉快了哈哈(哪来的自信) 1.RTP协议接受数据 #region 1-RTP协议变量声明 RTPSession session; RTPReceiver receiver; ...

  10. jasper 常用知识点总结

    1.应用: 列头 "YYYY-MM" 格式转化为 "MM YYYY"格式, eg : Date1 = 2014-11 new java.text.SimpleD ...