"object"
}
function isFunction(value) {
return type(value) == "function"
}
function isWindow(obj) {
return obj != null && obj == obj.window
}
function isDocument(obj) {
return obj != null && obj.nodeType == obj.DOCUMENT_NODE
}
function isObject(obj) {
return type(obj) == "object"
}
//对于通过字面量定义的对象和new Object的对象返回true,new Object时传参数的返回false
//可参考http://snandy.iteye.com/blog/663245
function isPlainObject(obj) {
return isObject(obj) && !isWindow(obj) && obj.__proto__ == Object.prototype
}
function isArray(value) {
return value instanceof Array
}
//类数组,比如nodeList,这个只是做最简单的判断,如果给一个对象定义一个值为数据的length属性,它同样会返回true
function likeArray(obj) {
return typeof obj.length == 'number'
}
//清除给定的参数中的null或undefined,注意0==null,'' == null为false
function compact(array) {
return filter.call(array, function(item) {
return item != null
})
}
//类似得到一个数组的副本
function flatten(array) {
return array.length > 0 ? $.fn.concat.apply([], array) : array
}
//将字符串转成驼峰式的格式
camelize = function(str) {
return str.replace(/-+(.)?/g, function(match, chr) {
return chr ? chr.toUpperCase() : ''
})
}
//将字符串格式化成-拼接的形式,一般用在样式属性上,比如border-width
function dasherize(str) {
return str.replace(/::/g, '/') //将::替换成/
.replace(/([A-Z]+)([A-Z][a-z])/g, '$1_$2') //在大小写字符之间插入_,大写在前,比如AAAbb,得到AA_Abb
.replace(/([a-z\d])([A-Z])/g, '$1_$2') //在大小写字符之间插入_,小写或数字在前,比如bbbAaa,得到bbb_Aaa
.replace(/_/g, '-') //将_替换成-
.toLowerCase() //转成小写
}
//数组去重,如果该条数据在数组中的位置与循环的索引值不相同,则说明数组中有与其相同的值
uniq = function(array) {
return filter.call(array, function(item, idx) {
return array.indexOf(item) == idx
})
}
//将给定的参数生成正则
function classRE(name) {
//classCache,缓存正则
return name in classCache ? classCache[name] : (classCache[name] = new RegExp('(^
关键词:zepto是啥