Quirrel4.41.0

array

Methods on every array.

Functions

appendarray.append(value, ...): anyAdds one or more values to the end of the array.
applyarray.apply(callback: function): anyReplaces every element with the result of callback on it.
clearclear(): anyRemoves every element from the array.
cloneclone(): anyMakes a shallow copy of the array.
constructorconstructor(size: number, [default_value], ...): anyCreates an array of size elements, each set to default_value.
containsarray.contains(value): anyReports whether any element equals value.
eacharray.each(callback: function): anyCalls callback once per element, in order.
extendarray.extend(other: array, ...): anyAppends every element of other to this array.
filterarray.filter(callback: function): anyCollects the elements for which callback returns a true value.
findindexpure array.findindex(callback: function): anyFinds the index of the first element for which callback returns a true value.
findvaluepure array.findvalue(predicate: function, [default_value], ...): anyFinds the first element for which predicate returns a true value.
hasindexpure array.hasindex(index: number): anyReports whether index is a valid element index.
hasvaluepure array.hasvalue(value): anyReports whether any element equals value.
indexofpure array.indexof(value): anyFinds the index of the first element that equals value.
insertarray.insert(index: number, value): anyInserts value before the element currently at index, shifting the rest up by one.
is_frozenis_frozen(): anyReports whether this array reference is frozen.
lenpure array.len(): anyReturns the number of elements in the array.
maparray.map(callback: function): anyBuilds a new array from the results of callback on each element.
poparray.pop(): anyRemoves and returns the last element.
reducearray.reduce(callback: function, [initial], ...): anyFolds the array down to one value by repeatedly combining an accumulator with each element.
removearray.remove(index: number): anyRemoves the element at index, shifting the rest down by one.
replacearray.replace(other: array): anyDeprecated alias of replace_with.
replace_witharray.replace_with(other: array): anyOverwrites this array's elements with other's.
resizearray.resize(size: number, ...): anyGrows or shrinks the array to size elements.
reversearray.reverse(): anyReverses the array in place.
slicearray.slice([start: number, end: number], ...): anyCopies the elements from start up to, but not including, end.
sortarray.sort([comparator: function], ...): anySorts the array in place.
swaparray.swap(index1: number, index2: number): anySwaps the elements at index1 and index2.
toparray.top(): anyReturns the last element without removing it.
tostringtostring(): anyReturns the default text representation of this array.
totablepure array.totable(): anyBuilds a table from the array's elements.
weakrefweakref(): anyReturns a weak reference to this array.