数组
一份参考文档,列出了支持数组
表达式中数据转换的内置便利函数。平均值():数字
Returns the value of elements in an array
块(大小:数字):数组
Splits arrays into chunks with a length of size
函数参数
sizeRequiredNumber
每个块的大小。
compact():数组
Removes empty values from the array.
差异(arr:数组):数组
Compares two arrays. Returns all elements in the base array that aren't present in arr.
函数参数
arrRequiredArray
要与基础数组进行比较的数组。
交集(arr:数组):数组
Compares two arrays. Returns all elements in the base array that are present in arr.
函数参数
arrRequiredArray
要与基础数组进行比较的数组。
first():数组项
Returns the first element of the array.
isEmpty(): 布尔值
Checks if the array doesn't have any elements.
isNotEmpty(): 布尔值
Checks if the array has elements.
last():数组项
Returns the last element of the array.
max():数字
Returns the highest value in an array.
合并(arr:数组):数组
Merges two Object-arrays into one array by merging the key-value pairs of each element.
函数参数
arrRequiredArray
要合并到基础数组的数组。
min():数字
Gets the minimum value from a number-only array.
pluck(fieldName?:字符串):数组
Returns an array of Objects where keys equal the given field names.
函数参数
fieldNameOptionalString
您要检索的密钥。您可以输入任意数量的密钥,并以逗号分隔的字符串形式输入。
randomItem():数组项
Returns a random element from an array.
删除重复项(键?:字符串):数组
Removes duplicates from an array.
函数参数
keyOptionalString
一个键或以逗号分隔的键列表,用于检查重复项。
renameKeys(从:字符串,到:字符串):数组
Renames all matching keys in the array. You can rename more than one key by entering a series of comma separated strings, in the pattern oldKeyName, newKeyName.
函数参数
fromRequiredString
您想要重命名的键。
toRequiredString
新名字。
smartJoin(keyField:String,nameField:String):数组
Operates on an array of objects where each object contains key-value pairs. Creates a new object containing key-value pairs, where the key is the value of the first pair, and the value is the value of the second pair. Removes non-matching and empty values and trims any whitespace before joining.
函数参数
keyFieldRequiredString
加入的钥匙。
nameFieldRequiredString
加入的值。
例子
基本用法
1 2 3 4 | |
sum():数字
Returns the total sum all the values in an array of parsable numbers.
toJsonString(): 字符串
Convert an array to a JSON string. Equivalent of
JSON.stringify.
联合(arr:数组):数组
Concatenates two arrays and then removes duplicate.
函数参数
arrRequiredArray
要与基础数组进行比较的数组。
唯一(键?:字符串):数组
Remove duplicates from an array.
函数参数
keyOptionalString
一个键或以逗号分隔的键列表,用于检查重复项。