摘要: YUI原码YUI indexOfYArray.indexOf = Lang._isNative(Native.indexOf) ? function (array, value, from) { return Native.indexOf.call(array, value, from);} : function (array, value, from) { // http://es5.github.com/#x15.4.4.14 var len = array.length; from = +from || 0; from = (from > 0 || -1) ... 阅读全文
posted @ 2013-08-28 23:39 独角xi 阅读(206) 评论(0) 推荐(0) 编辑
摘要: hash就是把两个参数合并成一个类似hashMap结构的对象,用第一个数组的元素为key,第二个的为value,如果第二个参数未指定,则把对象的对应的值置为trueYUI原码YUI hashYArray.hash = function (keys, values) { var hash = {}, vlen = (values && values.length) || 0, i, len; for (i = 0, len = keys.length; i i && i in values ? values[i] : true; } ... 阅读全文
posted @ 2013-08-28 22:52 独角xi 阅读(248) 评论(0) 推荐(0) 编辑
摘要: 1. yui-each原码:遍历YArray.each = YArray.forEach = Lang._isNative(Native.forEach) ? function (array, fn, thisObj) { Native.forEach.call(array || [], fn, thisObj || Y); return Y;} : function (array, fn, thisObj) { for (var i = 0, len = (array && array.length) || 0; i < len; ++i) { if (i i... 阅读全文
posted @ 2013-08-28 22:28 独角xi 阅读(390) 评论(0) 推荐(0) 编辑
摘要: YUI.Array.dedupe函数,如果传参为有length属性,返回一个去除掉重复项('1’ 与1 | true 与'true’认为相等)的参数数组副本,如果传参的length为undefined,那么返回一个空数组[],如果传参没length属性,抛出一个类型错误数组去重YArray.dedupe = Lang._isNative(Object.create) ? function (array) { var hash = Object.create(null), results = [], i, item, len; for (i = 0,... 阅读全文
posted @ 2013-08-28 20:07 独角xi 阅读(343) 评论(0) 推荐(0) 编辑
摘要: 创建一个具有指定原型且可选择性地包含指定属性的对象。Object.create(prototype, descriptors)参数 prototype必需。 要用作原型的对象。 可为 null。 descriptors可选。 包含一个或多个属性描述符的 JavaScript 对象。数据属性 是可获取和设置值的属性。 数据属性描述符包含一个 value 特性以及 writable、enumerable 和 configurable 特性。 如果未指定最后三个特性,则它们默认为 false。 只要检索或设置该值,访问器属性 就会调用用户提供的函数。 访问器属性描述符包含 set 特性和/或 get 阅读全文
posted @ 2013-08-28 19:44 独角xi 阅读(405) 评论(0) 推荐(0) 编辑
摘要: YUI的构建数组,将类数组转换成真正的数组,从而可以使用数组的所有方法数组构建 //真正的数组返回1,类数组返回2,其余的返回0 YArray.test = function (obj) { var result = 0; if (Lang.isArray(obj)) { result = 1; } else if (Lang.isObject(obj)) { try { // indexed, but no tagName (element) or scrollTo/document (window. From D... 阅读全文
posted @ 2013-08-28 18:16 独角xi 阅读(140) 评论(0) 推荐(0) 编辑
摘要: YUI.UA是针对javascript的宿主环境检测的一个检测对象,返回的是一系统关于当前宿主的信息1.对象相关信息列表及userAgent检测对象o = { ie: 0, //ie Mozilla/5.0 (compatible; MSIE 10.0; Windows NT 6.1; WOW64; Trident/6.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0; .NET4.0C; .NET4.0E) opera: 0... 阅读全文
posted @ 2013-08-28 14:49 独角xi 阅读(472) 评论(0) 推荐(0) 编辑
摘要: 1.首先定义一个关于类型的对象,及相关变量类型判断对象ar L = Y.Lang || (Y.Lang = {}),STRING_PROTO = String.prototype,TOSTRING = Object.prototype.toString,TYPES = { 'undefined' : 'undefined', 'number' : 'number', 'boolean' : 'boolean', 'string' : 'string', '[o 阅读全文
posted @ 2013-08-28 11:10 独角xi 阅读(205) 评论(0) 推荐(0) 编辑