$A = (iterable):Convert the iterable into an array. If the iterable defines the toArray method, call this method. Otherwise, use the length attribute of the iterable for enumeration. If the iterable does not have a length attribute, return an empty array[]
In addition to extending the method of Enumerable object, the Array object also extends the following methods.
Note that the following methods do not change the original array except clear, but return a new array:
clear():Clear the array, use = 0
first():Return the first element
last():Return the last element
compact():Remove elements with null or undefined values in the array
flatten():Flatten the array, for example [3,4,[6,7]] to [3,4,6,7]
without():Remove the specified element, you can specify multiple values, such as [4,56,7,8].without(4,7) Returns [56,8]
indexOf(object):Returns the index of the specified element in the array, if not included, returns -1
reverse(inline):The enhancement of the Array built-in function reverse. When inline is true, it changes the value of the original array like the built-in reverse function, otherwise the original value will not be changed.
reduce():If the array has only one element, then return this element, otherwise return the array itself
uniq():Return an array without duplicate elements
clone():Returns an array that is the same as the array. The toArray method in Array overrides the toArray method in Enumerable and points to this method.
inspect():Similar to the toString method of an array, it returns the string representation of the object, for example [2,3].inspect() returns "[2,3]"
In addition to extending the method of Enumerable object, the Array object also extends the following methods.
Note that the following methods do not change the original array except clear, but return a new array:
clear():Clear the array, use = 0
first():Return the first element
last():Return the last element
compact():Remove elements with null or undefined values in the array
flatten():Flatten the array, for example [3,4,[6,7]] to [3,4,6,7]
without():Remove the specified element, you can specify multiple values, such as [4,56,7,8].without(4,7) Returns [56,8]
indexOf(object):Returns the index of the specified element in the array, if not included, returns -1
reverse(inline):The enhancement of the Array built-in function reverse. When inline is true, it changes the value of the original array like the built-in reverse function, otherwise the original value will not be changed.
reduce():If the array has only one element, then return this element, otherwise return the array itself
uniq():Return an array without duplicate elements
clone():Returns an array that is the same as the array. The toArray method in Array overrides the toArray method in Enumerable and points to this method.
inspect():Similar to the toString method of an array, it returns the string representation of the object, for example [2,3].inspect() returns "[2,3]"