Docly Developers
Section23 pages

Array functions

Functions to add, get and remove items from arrays.

Array.concat(items...?)Returns a new array with the items of this array followed by the arguments. Array arguments are spread into the result; any other value…Array.every(callback)Tests whether every item passes the test function. Stops at the first item for which the function returns a falsy value.Array.filter(filter)Returns the items in an array that matches the filter function.Array.find(filter)Returns the first item for which the function returns a truthy value.Array.forEach(callback)Iterates all items in the array and executes a function passing the array item as a parameter.Array.groupBy(key)Docly-specific — not part of standard JavaScript (standard JavaScript has Object.groupBy(), which HashJS does not support). Groups the…Array.indexOf(item, fromIndex?)Returns the index of the first item that equals the given value.Array.join(separator?)Joins all elements in an array into a string.Array.length()Returns the number of items in the array. Note: assigning to length (arr.length = 0) does not shorten the array in HashJS — use splice(0)…Array.pop()The pop() method removes the last element from an array and returns that element. This method changes the length of the array.Array.push(items...)Adds one or more items to the end of the array. To add the items of another array, use spread: arr.push(...other).Array.reverse()The reverse() method reverses an array in place and returns the reference to the same array.Array.shift()The shift() method removes the first element from an array and returns that element. This method changes the length of the array.Array.isArray(value)Determines whether the value is an array. Text, objects and Set are not arrays.Array.slice(start, end?)Returns a new array of a part of the array. Does not modify the existing array.Array.some(evaluator)Tests whether at least one element in the array returns true with provided evaluator function.Array.sort(sorter?)Sorts the array in place and returns it. Without a compare function, the items are converted to text and sorted by character code, as in…Array.splice(start, deleteCount?, item1...N?)Changes the contents of an array by removing or replacing existing elements and/or adding new elements at specified index.Array.map(callback)Returns a new array with the result of calling a function on every item. The original array is not changed. A second argument (thisArg) is…Array.reduce(callback, initialValue?)Runs a function on each item, carrying a value (the accumulator) from one item to the next, and returns the final value. Typical use: sums…Array.includes(value, fromIndex?)Checks whether the array contains a value.Array.findIndex(callback)Returns the index of the first item for which the function returns a truthy value.Array.flat(depth?)Returns a new array with nested arrays flattened into it, down to the given depth. Text is not split into characters.