├── Array(数组) ├── lodash_firstHead.js ├── lodash_last.js ├── lodash_fromPairs.js ├── lodash_initial.js ├── lodash_flattenDeep.js ├── lodash.intersection.js ├── lodash_difference.js ├── lodash_drop.js ├── lodash_flatten.js ├── lodash_dropRight.js ├── lodash_compact.js ├── lodash_dropWhile.js ├── lodash_dropRightWhile.js ├── lodash_fill.js ├── lodash_concat.js ├── lodash_intersection.js ├── lodash_flattenDepth.js ├── lodash_chunk.js ├── lodash_indexOf.js ├── lodash_differenceBy.js ├── lodash_differenceWith.js ├── lodash_findIndex.js └── lodash_findLastIndex.js ├── Lang(类型转换与类型判断操作) ├── lodash_isObjectLike.js └── lodash_isLength.js └── README.md /Array(数组)/lodash_firstHead.js: -------------------------------------------------------------------------------- 1 | //head函数,获取数组的第一项 2 | 3 | function head(array){ 4 | return (array != null && array.length) 5 | ? array[0] 6 | : undefined 7 | } 8 | -------------------------------------------------------------------------------- /Array(数组)/lodash_last.js: -------------------------------------------------------------------------------- 1 | //last函数 获取数组的最后一项 2 | 3 | function last(array){ 4 | return (array != null && array.length) 5 | ? array[array.length - 1] 6 | : undefined 7 | } 8 | 9 | last([1, 2, 3]); 10 | // => 3 -------------------------------------------------------------------------------- /Array(数组)/lodash_fromPairs.js: -------------------------------------------------------------------------------- 1 | function fromPairs(pairs) { 2 | return pairs.reduce((result,[key,value]) => { 3 | result[key] = value 4 | return result; 5 | },{}) 6 | } 7 | 8 | fromPairs([['a', 1], ['b', 2]]); 9 | // => { 'a': 1, 'b': 2 } 10 | -------------------------------------------------------------------------------- /Array(数组)/lodash_initial.js: -------------------------------------------------------------------------------- 1 | //initial函数 去除最后一个元素 2 | 3 | function initial(array){ 4 | if(!Array.isArray(array) || array.length == 0){ 5 | return []; 6 | } 7 | return array.slice(0,array.length-1) 8 | } 9 | 10 | // 例子 11 | const result = initial([1, 2, 3]); 12 | console.log(result); // 输出 [1, 2] 13 | -------------------------------------------------------------------------------- /Array(数组)/lodash_flattenDeep.js: -------------------------------------------------------------------------------- 1 | function flattenDeep(array) { 2 | let result = [] 3 | 4 | for (const value of array) { 5 | if (Array.isArray(value)) { 6 | result.push(...flattenDeep(value)) 7 | } else { 8 | result.push(value) 9 | } 10 | } 11 | 12 | return result; 13 | } 14 | 15 | flattenDeep([1, [2, [3, [4]], 5]]); 16 | // => [1, 2, 3, 4, 5] 17 | -------------------------------------------------------------------------------- /Array(数组)/lodash.intersection.js: -------------------------------------------------------------------------------- 1 | function intersection(...arrays){ 2 | if (arrays.length === 0) { 3 | return [] 4 | } 5 | //reduce不能加第二个参数,因为使用的初始值是传入的第一个数组 6 | return arrays.reduce((acc,currentArray) => { 7 | return acc.filter(element => currentArray.includes(element)); 8 | }) 9 | } 10 | 11 | // 示例用法 12 | const result = intersection([2, 1], [2, 3],[]); 13 | console.log(result); // 输出 [2] 14 | -------------------------------------------------------------------------------- /Array(数组)/lodash_difference.js: -------------------------------------------------------------------------------- 1 | //difference方法,返回一个新数组,接受两个参数,创建一个array值的数组,每个值不包含在其给定的数组中 2 | 3 | function difference(array,...values){ 4 | //将所有排除的值合并为一个新的数组 5 | const exclusionArray = [].concat(...values); 6 | const result = array.filter(item => !exclusionArray.includes(item)) 7 | return result; 8 | } 9 | 10 | const result = difference([3, 2, 1], [4, 2]); 11 | console.log(result); 12 | // => [3, 1] 13 | -------------------------------------------------------------------------------- /Array(数组)/lodash_drop.js: -------------------------------------------------------------------------------- 1 | //drop 的作用是在移除数组中前 n 个数的元素,并将剩余的元素返回。如果指定的个数比数组的长度大,返回的是空数组。 2 | 3 | function drop(array,n=1){ 4 | const length = array == null ? 0 : array.length; 5 | return length ? array.slice(n < 0 ? 0 : n) : [] 6 | } 7 | 8 | drop([1, 2, 3]); 9 | // => [2, 3] 10 | 11 | drop([1, 2, 3], 2); 12 | // => [3] 13 | 14 | drop([1, 2, 3], 5); 15 | // => [] 16 | 17 | drop([1, 2, 3], 0); 18 | // => [1, 2, 3] -------------------------------------------------------------------------------- /Array(数组)/lodash_flatten.js: -------------------------------------------------------------------------------- 1 | function flatten(array) { 2 | const result = [] 3 | for (let i = 0; i < array.length; i++){ 4 | if (Array.isArray(array[i])) { 5 | for (let j = 0; j < array[i].length; j++){ 6 | result.push(array[i][j]); 7 | } 8 | } else { 9 | result.push(array[i]) 10 | } 11 | } 12 | return result; 13 | } 14 | 15 | flatten([1, [2, [3, [4]], 5]]); 16 | // => [1, 2, [3, [4]], 5] 17 | -------------------------------------------------------------------------------- /Array(数组)/lodash_dropRight.js: -------------------------------------------------------------------------------- 1 | //dropRight 的作用是在移除数组中后 n 个数的元素,并将剩余的元素返回。如果指定的个数比数组的长度大,返回的是空数组。 2 | 3 | function dropRight(array,n=1){ 4 | const length = array == null ? 0 : array.length; 5 | return length ? array.slice(0,length - n) : [] 6 | } 7 | 8 | dropRight([1, 2, 3]); 9 | // => [1, 2] 10 | 11 | dropRight([1, 2, 3], 2); 12 | // => [1] 13 | 14 | dropRight([1, 2, 3], 5); 15 | // => [] 16 | 17 | dropRight([1, 2, 3], 0); 18 | // => [1, 2, 3] -------------------------------------------------------------------------------- /Array(数组)/lodash_compact.js: -------------------------------------------------------------------------------- 1 | //compact函数用于去除数组中的假值,并返回由不为假值的元素组成的新数组 2 | //false,null,0,"",undefined,NaN都为假值 3 | 4 | 5 | function compact(array){ 6 | let result = []; 7 | let index = 0; 8 | if(array == null){ 9 | return result; 10 | } 11 | 12 | for(let i=0; i objects for ['pebbles'] 18 | -------------------------------------------------------------------------------- /Array(数组)/lodash_dropRightWhile.js: -------------------------------------------------------------------------------- 1 | function dropRightWhile (array,predicate) { 2 | let index = array.length - 1 3 | while (index >= 0 && predicate(array[index])) { 4 | index-- 5 | } 6 | return array.slice(0,index + 1) 7 | } 8 | 9 | 10 | var users = [ 11 | { 'user': 'barney', 'active': true }, 12 | { 'user': 'fred', 'active': false }, 13 | { 'user': 'pebbles', 'active': false } 14 | ]; 15 | 16 | dropRightWhile(users, function(o) { return !o.active; }); 17 | // => [ { user: 'barney', active: true } ] 18 | -------------------------------------------------------------------------------- /Array(数组)/lodash_fill.js: -------------------------------------------------------------------------------- 1 | //fill使用 value 值来填充(替换) array,从start位置开始, 到end位置结束(但不包含end位置)。 2 | //注意: 这个方法会改变 array(注:不是创建新数组)。 3 | 4 | function fill(array,value,start = 0, end = array.length){ 5 | for(let i = start ; i < end ; i++){ 6 | array[i] = value; 7 | } 8 | return array 9 | } 10 | 11 | var array = [1, 2, 3]; 12 | 13 | fill(array, 'a'); 14 | console.log(array); 15 | // => ['a', 'a', 'a'] 16 | 17 | fill(Array(3), 2); 18 | // => [2, 2, 2] 19 | 20 | fill([4, 6, 8, 10], '*', 1, 3); 21 | // => [4, '*', '*', 10] 22 | -------------------------------------------------------------------------------- /Array(数组)/lodash_concat.js: -------------------------------------------------------------------------------- 1 | //concat 创建一个新数组,将array与任何数组 或 值连接在一起 2 | 3 | function concat(array, ...values) { 4 | const result = array.slice(); 5 | for(const value of values){ 6 | if(Array.isArray(value)){ 7 | result.push(...value); 8 | }else{ 9 | result.push(value); 10 | } 11 | } 12 | return result; 13 | } 14 | 15 | var array = [1]; 16 | var other = concat(array, 2, [3], [[4]]); 17 | 18 | console.log(other); 19 | // => [1, 2, 3, [4]] 20 | 21 | console.log(array); 22 | // => [1] -------------------------------------------------------------------------------- /Array(数组)/lodash_intersection.js: -------------------------------------------------------------------------------- 1 | //intersection函数 返回一个包含所有传入数组交集元素的新数组。 2 | 3 | function intersection(...arrays){ 4 | if(arrays.length === 0){ 5 | return [] 6 | } 7 | const baseArray = arrays[0]; 8 | 9 | const result = baseArray.filter((element)=>{ 10 | //every这个方法会遍历数组中的每个元素,对每个元素执行指定的测试函数,只有当所有元素都满足条件时,every 方法才会返回 true,否则返回 false。 11 | return arrays.every((array)=>array.includes(element)); 12 | }) 13 | return result; 14 | } 15 | 16 | // 例子 17 | const result = intersection([2, 1], [2, 3]); 18 | console.log(result); // 输出 [2] -------------------------------------------------------------------------------- /Array(数组)/lodash_flattenDepth.js: -------------------------------------------------------------------------------- 1 | //flattenDepth 用来展平数组,可以指定展平的深度。 2 | //@param {Array} array : 需要展平的数组 3 | //@param {Number} depth: 展平的深度 4 | 5 | function flattenDepth(array,depth) { 6 | if(depth <= 0){ 7 | return array.slice() 8 | } 9 | let result = []; 10 | for(const value of array){ 11 | if(Array.isArray(value)){ 12 | result.push(...flattenDepth(value,depth-1)) 13 | }else{ 14 | result.push(value); 15 | } 16 | } 17 | return result 18 | } 19 | 20 | var array = [1, [2, [3, [4]], 5]]; 21 | 22 | flattenDepth(array, 1); 23 | // => [1, 2, [3, [4]], 5] 24 | 25 | flattenDepth(array, 2); 26 | // => [1, 2, 3, [4], 5] -------------------------------------------------------------------------------- /Lang(类型转换与类型判断操作)/lodash_isObjectLike.js: -------------------------------------------------------------------------------- 1 | //isObjectLike返回值是否是类对象 2 | //就是用typeof操作符,如果返回值是object,并且值不为null,就认为是类对象 3 | // Undefined 'undefined' 4 | // Null 'object' 5 | // Boolean 'boolean' 6 | // Number 'number' 7 | // String 'string' 8 | // Symbol 'symbol' 9 | // 函数对象 'function' 10 | // 任意其它对象 'object' 11 | //上面是typeof的返回值,这里就需要注意,typeof null = 'object 12 | 13 | function isObjectLike(value){ 14 | return typeof value == 'object' && value != null 15 | } 16 | 17 | isObjectLike({}); 18 | // => true 19 | 20 | isObjectLike([1, 2, 3]); 21 | // => true 22 | 23 | isObjectLike(null); 24 | // => false 25 | 26 | 27 | 28 | 29 | -------------------------------------------------------------------------------- /Array(数组)/lodash_chunk.js: -------------------------------------------------------------------------------- 1 | //chunk函数可以将一个数组,切割成指定大小的块,返回由这些块组成的新数组 2 | //chunk函数在前端可以缓解一些性能问题。例如大量操作DOM的时候,可以分块让浏览器在空闲的时候处理,避免页面卡死。 3 | 4 | function chunk(array,size){ 5 | size = Math.max(size,0) 6 | const length = array == null ? 0 : array.length 7 | if(!length || size < 1){ 8 | return [] 9 | } 10 | 11 | let index = 0 ; 12 | let resIndex = 0; 13 | const result = new Array(Math.ceil(length / size)) 14 | while(index < length){ 15 | result[resIndex++] = array.slice(index,(index += size)) 16 | } 17 | return result 18 | } 19 | 20 | console.log(chunk(['a', 'b', 'c', 'd'], 2)); 21 | // => [['a', 'b'], ['c', 'd']] 22 | 23 | console.log(chunk(['a', 'b', 'c', 'd'], 3)); 24 | // => [['a', 'b', 'c'], ['d']] -------------------------------------------------------------------------------- /Lang(类型转换与类型判断操作)/lodash_isLength.js: -------------------------------------------------------------------------------- 1 | //isLength用于判断所传入的值是否为数组或者类数组可用的length属性 2 | 3 | const MAX_SAFE_INTEGER = 9007199254740991 4 | function isLength(value){ 5 | return typeof value == 'number' && value > -1 && value % 1 == 0 && value <= MAX_SAFE_INTEGER 6 | } 7 | /* 8 | typeof value == 'number' ,很明显,length 属性必须是 number 类型。 9 | 10 | value > -1 ,正常的数组下标是从 0 开始的,因此可以用大于 -1 来判断。 11 | 12 | value % 1 == 0 ,数组的下标必需是整数,这个可以与 1 取模来判断,这个条件和上一个条件合起来就是 length 必须为大于 -1 的整数。 13 | 14 | value <= MAX_SAFE_INTEGER ,众所周知,js 所能表达的整数范围是有限的,length 是数字,也受这个限制,因此最后要判断其数值不能超过 js 所表达的最大正整数。 15 | 16 | 因此可以总结出来,是否为合法的数组 length 属性包含下面几个条件: 17 | 是数字 18 | 大于 -1 19 | 整数 20 | 数值在安全范围内 21 | 这几个条件的判断顺序也是经过精心安排的,越排在前面的,使用的频率越高,这样可以避免无效的判断。 22 | */ 23 | 24 | -------------------------------------------------------------------------------- /Array(数组)/lodash_indexOf.js: -------------------------------------------------------------------------------- 1 | //indexOf 接收三个参数,第一个 array 为数组,第二个参数 value 为需要查找的值, 2 | //第三个 fromIndex 参数和数组的 indexOf 方法一样,用来指定开始查找的位置。 3 | 4 | function indexOf(array,value,fromIndex = 0){ 5 | const length = array == null ? 0 : array.length 6 | if(!length){ 7 | return -1; 8 | } 9 | if(fromIndex < 0){ 10 | fromIndex = array.length + fromIndex; 11 | if(fromIndex < 0 ){ 12 | fromIndex = 0 13 | } 14 | } 15 | 16 | for(let i = fromIndex ; i < length ; i++){ 17 | if(array[i] === value){ 18 | return i; 19 | } 20 | } 21 | 22 | return -1; 23 | } 24 | 25 | console.log(indexOf([1, 2, 1, 2], 2)); // => 1 26 | console.log(indexOf([1, 2, 1, 2], 2, 2)); // => 3 -------------------------------------------------------------------------------- /Array(数组)/lodash_differenceBy.js: -------------------------------------------------------------------------------- 1 | //第三个参数是迭代器 2 | function differenceBy(array,values,iteratee){ 3 | if(!Array.isArray(array) || !Array.isArray(values)){ 4 | throw new Error('Expected arrays for both the array and values arguments') 5 | } 6 | if(typeof iteratee === 'string'){ 7 | const key = iteratee; 8 | iteratee = (obj) => obj[key] 9 | }else if(typeof iteratee !== 'function'){ 10 | iteratee = (obj) => obj 11 | } 12 | 13 | const set = new Set(values.map(item => {return iteratee(item)})) 14 | return array.filter((arr) => !set.has(iteratee(arr))) 15 | } 16 | 17 | differenceBy([3.1, 2.2, 1.3], [4.4, 2.5], Math.floor); 18 | // => [3.1, 1.3] 19 | 20 | differenceBy([{ 'x': 2 }, { 'x': 1 }], [{ 'x': 1 }], 'x'); 21 | // => [{ 'x': 2 }] -------------------------------------------------------------------------------- /Array(数组)/lodash_differenceWith.js: -------------------------------------------------------------------------------- 1 | function differenceWith(array,values,comparator){ 2 | const result = [] 3 | 4 | for(let i = 0 ; i < array.length ; i++){ 5 | let isFount = false; 6 | for(let j = 0 ; j < values.length ;j++){ 7 | if(comparator(array[i],values[j])){ 8 | isFount = true; 9 | break; 10 | } 11 | } 12 | if(!isFount){ 13 | result.push(array[i]) 14 | } 15 | } 16 | return result 17 | } 18 | 19 | function isEqual(a,b){ 20 | const keysA = Object.keys(a); 21 | const keysB = Object.keys(b); 22 | if(keysA.length !== keysB.length){ 23 | return false; 24 | } 25 | for(let key of keysA){ 26 | const valA = a[key]; 27 | const valB = b[key]; 28 | 29 | if(valA !== valB){ 30 | return false 31 | } 32 | } 33 | return true; 34 | } 35 | 36 | var objects = [{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 }]; 37 | 38 | differenceWith(objects, [{ 'x': 1, 'y': 2 }], isEqual); 39 | // => [{ 'x': 2, 'y': 1 }] 40 | -------------------------------------------------------------------------------- /Array(数组)/lodash_findIndex.js: -------------------------------------------------------------------------------- 1 | function findIndex(array,predicate,fromIndex = 0){ 2 | if(!Array.isArray(array)){ 3 | throw new Error('The first argument must be an array.') 4 | } 5 | if(typeof predicate === 'function'){ 6 | for (let i = fromIndex; i < array.length; i++) { 7 | if (predicate(array[i])) { 8 | return i; 9 | } 10 | } 11 | }else if(typeof predicate === 'object'){ 12 | for(let i = fromIndex; i < array.length; i++) { 13 | const item = array[i]; 14 | if(matchesPredicate(item,predicate)){ 15 | return i; 16 | } 17 | } 18 | }else if(typeof predicate === 'string'){ 19 | for(let i = fromIndex; i < array.length; i++) { 20 | if(array[i][predicate]){ 21 | return i 22 | } 23 | } 24 | } 25 | return -1; 26 | } 27 | 28 | function matchesPredicate(item,predicate){ 29 | if(typeof predicate === 'object'){ 30 | if(Object.keys(item).length !== Object.keys(predicate).length){ 31 | return false; 32 | } 33 | for(const key in predicate){ 34 | if(!predicate.hasOwnProperty(key) || item[key] !== predicate[key]){ 35 | return false 36 | } 37 | } 38 | return true; 39 | } 40 | return false; 41 | } 42 | 43 | var users = [ 44 | { 'user': 'barney', 'active': false }, 45 | { 'user': 'fred', 'active': false }, 46 | { 'user': 'pebbles', 'active': true } 47 | ]; 48 | 49 | console.log(findIndex(users, function(o) { return o.user == 'barney'; })); // 0 50 | console.log(findIndex(users, { 'user': 'fred', 'active': false })); // 1 51 | console.log(findIndex(users, 'active')); // 2 52 | -------------------------------------------------------------------------------- /Array(数组)/lodash_findLastIndex.js: -------------------------------------------------------------------------------- 1 | function findLastIndex(array,predicate,fromIndex = array.length - 1){ 2 | if(!Array.isArray(array)){ 3 | throw new Error('The first argument must be an array.') 4 | } 5 | if(typeof predicate === 'function'){ 6 | for(let i = fromIndex ; i >= 0 ; i--){ 7 | if(predicate(array[i])){ 8 | return i; 9 | } 10 | } 11 | }else if(typeof predicate === 'object'){ 12 | for(let i = fromIndex ; i >= 0 ; i--){ 13 | const item = array[i] 14 | if(matchesPredicate(item,predicate)){ 15 | return i; 16 | } 17 | } 18 | }else if(typeof predicate === 'string'){ 19 | for(let i = fromIndex ; i >= 0 ; i--){ 20 | if(array[i][predicate]){ 21 | return i 22 | } 23 | } 24 | } 25 | return -1; 26 | } 27 | 28 | function matchesPredicate(item,predicate){ 29 | 30 | if(typeof predicate === 'object'){ 31 | if(Object.keys(item).length !== Object.keys(predicate).length){ 32 | return false; 33 | } 34 | for(const key in predicate){ 35 | //这个检查确保只比较predicate对象自身的属性, 36 | //而不包括从原型链继承的属性。这是因为for...in循环会遍历对象及其原型链上的所有可枚举属性。 37 | if(!predicate.hasOwnProperty(key) || item[key] !== predicate[key]){ 38 | return false; 39 | } 40 | } 41 | return true; 42 | } 43 | return false; 44 | } 45 | 46 | var users = [ 47 | { 'user': 'barney', 'active': true }, 48 | { 'user': 'fred', 'active': false }, 49 | { 'user': 'pebbles', 'active': false } 50 | ]; 51 | 52 | console.log(findLastIndex(users, function(o) { return o.user == 'pebbles'; }));// => 2 53 | console.log(findLastIndex(users, { 'user': 'barney', 'active': true }));// => 0 54 | console.log(findLastIndex(users, 'active'));// => 0 -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Lodash源码 2 | 英文文档:https://lodash.com/docs/4.17.15 3 | 4 | 中文文档:https://www.lodashjs.com/docs/lodash.chunk 5 | 6 | 中文文档解析版本:https://lodash.shujuwajue.com/array/flattendeep 7 | 8 | # Array(数组) 9 | 10 | ## chunk 11 | 12 | chunk函数可以将一个数组,切割成指定大小的块,返回由这些块组成的新数组 13 | chunk函数在前端可以缓解一些性能问题。例如大量操作DOM的时候,可以分块让浏览器在空闲的时候处理,避免页面卡死。 14 | 15 | ## compact 16 | 17 | compact函数用于去除数组中的假值,并返回由不为假值的元素组成的新数组 18 | false,null,0,"",undefined,NaN都为假值 19 | 20 | ## concat 21 | 22 | 创建一个新数组,将array与任何数组 或 值连接在一起 23 | 24 | ## difference 25 | 26 | difference方法,返回一个新数组,接受两个参数,创建一个array值的数组,每个值不包含在其给定的数组中 27 | 28 | ## differenceBy 29 | 这个方法类似_.difference ,除了它接受一个 iteratee (注:迭代器), 调用array 和 values 中的每个元素以产生比较的标准。 结果值是从第一数组中选择。 30 | 注意: 这个方法会返回一个新数组。 31 | 32 | ## differenceWith 33 | 34 | 这个方法类似difference ,除了它接受一个 comparator (注:比较器),它调用比较array,values中的元素。 结果值是从第一数组中选择。comparator 调用参数有两个:(arrVal, othVal)。 35 | 36 | ## drop 37 | 38 | drop 的作用是在移除数组中前 n 个数的元素,并将剩余的元素返回。如果指定的个数比数组的长度大,返回的是空数组。 39 | 40 | ## dropRight 41 | 42 | dropRight 的作用是在移除数组中后 n 个数的元素,并将剩余的元素返回。如果指定的个数比数组的长度大,返回的是空数组。 43 | 44 | ## dropRightWhile(结尾丢失元素) 45 | 46 | 从数组的后面开始进行判断,如果返回true就丢掉元素,直到返回false结束,返回剩下的元素。 47 | 48 | ## dropWhile(开头丢失元素) 49 | 50 | 从数组的前面开始进行判断,如果返回true就丢掉元素,直到返回false结束,返回剩下的元素。 51 | 52 | ## fill 53 | 54 | fill使用 value 值来填充(替换) array,从start位置开始, 到end位置结束(但不包含end位置)。 55 | 56 | ## findIndex 57 | 58 | 该方法类似_.find,区别是该方法返回第一个通过 predicate 判断为真值的元素的索引值(index),而不是元素本身。 59 | 60 | ## findLastIndex 61 | 62 | 这个方式类似_.findIndex, 区别是它是从右到左的迭代集合array中的元素。 63 | 64 | ## head 65 | 66 | 获取数组的第一项 67 | 68 | ## flatten(减少一层嵌套) 69 | 70 | 减少一层array嵌套深度 71 | 72 | ## flattenDeep(递归为一维数组) 73 | 74 | 将array递归为一维数组。 75 | 76 | ## flattenDepth 77 | 78 | 用来展平数组,可以指定展平的深度。 79 | 80 | ## fromPairs 81 | 82 | 返回一个由键值对pairs构成的对象 83 | 84 | ## indexOf 85 | 86 | 用于查找指定元素的下标,indexOf 接收三个参数,第一个 array 为数组,第二个参数 value 为需要查找的值,第三个 fromIndex 参数和数组的 indexOf 方法一样,用来指定开始查找的位置。 87 | 88 | ## initial 89 | 90 | 去除数组的最后一个元素 91 | 92 | ## intersection 93 | 94 | 获取传入数组的交集 95 | 96 | ## last 97 | 98 | 获取数组的最后一项 99 | 100 | # Lang(类型转换与类型判断操作) 101 | 102 | ## isLength 103 | 104 | isLength用于判断所传入的值是否为数组或者类数组可用的length属性 105 | 106 | ## isObjectList 107 | 108 | isObjectLike返回值是否是类对象 109 | --------------------------------------------------------------------------------