ArrayUtil

ArrayUtil

new ArrayUtil()

Source:
Author:
  • ycx

Methods

(static) complement(…arr)

Source:
获取补集
本方法用于获取各个数组不同项
Parameters:
Name Type Attributes Description
arr * <repeatable>
Returns:

(static) contains(arr, element) → {boolean}

Source:
判断数组是否包含某个元素
Parameters:
Name Type Description
arr Array 源数组
element * 被包含的元素
Returns:
是否包含
Type
boolean

(static) defaultIfEmpty(arr, defaultArr) → {Array}

Source:
Author:
  • ycx
给定数组如果为空,返回默认数组对象
Parameters:
Name Type Description
arr Array 数组对象
defaultArr Array 默认的数组对象
Returns:
Type
Array

(static) hasNull(arr) → {boolean}

Source:
Author:
  • ycx 判断数组中是否包含null
Parameters:
Name Type Description
arr Array 被检测的数组
Returns:
Type
boolean

(static) hasUndefined(arr) → {boolean}

Source:
Author:
  • ycx 判断数组中是否包含 undefined
Parameters:
Name Type Description
arr Array 数组列表
Returns:
是否包含
Type
boolean

(static) intersect(…arr)

Source:
获取交集 A∩B
集合论:设A,B是两个集合,由 属于集合A且属于集合B的元素所组成 的集合,叫做集合A与集合B的交集
Parameters:
Name Type Attributes Description
arr <repeatable>
Returns:

(static) isEmpty(arr) → {boolean}

Source:
Author:
  • ycx
Parameters:
Name Type Description
arr Array 数组
Returns:
是否为空
Type
boolean

(static) isNotEmpty(arr) → {boolean}

Source:
Author:
  • ycx 判断数组是否不包含空
Parameters:
Name Type Description
arr 数组
Returns:
Type
boolean

(static) minus(sourceArr, anotherArr)

Source:
获取差集(相对)
注:集合论可分为朴素集合论和相对集合论 集合论:设A,B是两个集合,由 属于集合A但不属于集合B的元素 所组成的集合,叫做集合A与集合B的差集(也就是A减去B中与A相同的元素,)
Parameters:
Name Type Description
sourceArr
anotherArr
Returns:

(static) remove(arr, element) → {Array.<*>}

Source:
移除数组中匹配相同元素
Parameters:
Name Type Description
arr Array.<*>
element *
Returns:
Type
Array.<*>

(static) removeOne(arr, element) → {Array.<*>}

Source:
移除数组中一个匹配的元素
Parameters:
Name Type Description
arr Array.<*> 数组
element * 要移除的元素
Returns:
Type
Array.<*>

(static) unique(arr) → {Array.<*>}

Source:
去除数组中重复元素
Parameters:
Name Type Description
arr Array.<*> 源数组
Returns:
去重的后的数组
Type
Array.<*>

(static) uniquelize(…arr)

Source:
合并多个数组并且不重复
注:这是一种比较暴力的方式
Parameters:
Name Type Attributes Description
arr <repeatable>
Returns: