Tabular IQ

Overview

An array class for storing lists of objects or data.

Base Class

Object

Constructor

Array()
Array(length : Integer)
Array(elem_0 : Object, ... , elem_n : Object)

Arguments

length
The index of the highest element of array plus one. Only the number of elements in the Array if every index smaller than the highest index has an element.
elem0, ..., elemn
The first n elements of the new Array. n has to greater than 1.

Methods

Array.concat
Concatenates a number of elements to an Array.
Array.every
Tests whether all elements pass a test.
Array.filter
Creates a new array of the elements that pass a test.
Array.find
Returns the first element that passes a test.
Array.findIndex
Returns the index of the first element that passes a test.
Array.forEach
Calls a function once for each array element.
Array.includes
Determines whether an array contains an element.
Array.indexOf
Returns the first index at which an element is found.
Array.isArray
Determines whether a value is an Array.
Array.join
Returns the elements of an Array as a string.
Array.lastIndexOf
Returns the last index at which an element is found.
Array.map
Creates a new array from the results of a function.
Array.pop
Deletes and returns the last element of an Array.
Array.push
Appends a number of elements to the end of an Array.
Array.reduce
Reduces the array to a single value, front to back.
Array.reduceRight
Reduces the array to a single value, back to front.
Array.reverse
Reverses the order of elements in an Array.
Array.shift
Deletes and returns the first element of an Array.
Array.slice
Returns a selection of elements of an Array in a new Array.
Array.some
Tests whether any element passes a test.
Array.sort
Sorts the elements of an Array.
Array.splice
Returns and replaces a selection of elements of an Array in a new Array with other elements.
Array.toLocaleString
Returns a local specific string representation of an Array.
Array.toString
Returns a string representation of an Array.
Array.unshift
Prepends a number of elements to the beginning of an Array.

Inherited Methods

Object.assign
Copies properties from source objects to a target.
Object.entries
Returns an object's own enumerable [name, value] pairs.
Object.hasOwnProperty
Checks for the existence of an object property
Object.keys
Returns an object's own enumerable property names.
Object.valueOf
Returns the 'primitive' value of the object.
Object.values
Returns an object's own enumerable property values.

Example

// creating a simple array
const arr = ["aaa", "bbb", "ccc"];

for (let i = 0; i < arr.length; ++i) {
    alert(`element ${i} is ${arr[i]}`);
}

// sort an array of strings
const birds = ["Finch",
               "Bluebird",
               "Goose",
               "Sparrow",
               "Hummingbird",
               "Duck"];

birds.sort();
alert(birds);

// sort an array of numbers -- this requires a comparison function
// of our own, because by default the sort() method sorts as if all
// elements were strings
const numbers = [5, 4, 10, 50, 45, 52, 1, 12];

numbers.sort((a, b) => a - b);
alert(numbers);

Array.concat

function Array.concat(elem_n+1 : Object, ..., elem_n+m : Object) : Array(Object)

Arguments

elem_n+1, ..., elem_n+m
The elements to concatenate to the array. If a specified element in the parameter list is an array, the contents of the specified array are copied into the result.

Returns

Returns a new Array, created by concatenating the input elements to the array.

Description

Returns a new array, without modifying the original array, formed by concatenating the input elements with the elements of the array.

Array.every

function Array.every(callback : Function) : Boolean
function Array.every(callback : Function, this_arg : Object) : Boolean

Returns

True if every callback returned a truthy value, else false.

Description

Invokes callback with (element, index, array) for each assigned element until the callback returns a falsy value.

Array.filter

function Array.filter(callback : Function) : Array(Object)
function Array.filter(callback : Function, this_arg : Object) : Array(Object)

Returns

A new array of the elements that passed the test.

Description

Invokes callback with (element, index, array) for each assigned element and collects the elements for which the callback returns a truthy value.

Array.find

function Array.find(callback : Function) : Object
function Array.find(callback : Function, this_arg : Object) : Object

Returns

The first element that passed the test, or undefined.

Description

Invokes callback with (element, index, array) for every index (unassigned indexes are passed as undefined) until the callback returns a truthy value.

Array.findIndex

function Array.findIndex(callback : Function) : Integer
function Array.findIndex(callback : Function, this_arg : Object) : Integer

Returns

The first matching index, or -1.

Description

Like find, but returns the matching index instead of the element.

Array.forEach

function Array.forEach(callback : Function)
function Array.forEach(callback : Function, this_arg : Object)

Description

Invokes callback with (element, index, array) for each assigned element, front to back. this_arg, if supplied, is bound as 'this' inside the callback.

Array.includes

function Array.includes(search_element : Object) : Boolean
function Array.includes(search_element : Object, from_index : Integer) : Boolean

Returns

True if the element is found, false otherwise.

Description

Like indexOf, but returns a boolean and treats NaN as equal to NaN.

Array.indexOf

function Array.indexOf(search_element : Object) : Integer
function Array.indexOf(search_element : Object, from_index : Integer) : Integer

Returns

The first matching index, or -1 if the element is not found.

Description

Searches the array front to back for search_element using strict equality (===), starting at from_index (default 0; a negative value counts back from the end).

Array.isArray

function Array.isArray(value : Object) : Boolean

Returns

True if the value is an Array, false otherwise.

Description

Returns true if value is an Array object.

Array.join

function Array.join() : String
function Array.join(separator : String) : String

Arguments

separator
A string that will be used to separate the elements of the Array in the returned String.

Returns

Returns a string formed by converting all elements of array to strings and concatenating them with the separator added between elements. If a separator is not supplied, a "," is used.

Description

Joins the elements of the array into a string, where the individual elements of the array are separated by separator if it is specified, or by "," if the separator is not specified.

Array.lastIndexOf

function Array.lastIndexOf(search_element : Object) : Integer
function Array.lastIndexOf(search_element : Object, from_index : Integer) : Integer

Returns

The last matching index, or -1 if the element is not found.

Description

Searches the array back to front for search_element using strict equality (===), starting at from_index (default: the last element; a negative value counts back from the end).

Array.map

function Array.map(callback : Function) : Array(Object)
function Array.map(callback : Function, this_arg : Object) : Array(Object)

Returns

A new array of the callback's return values.

Description

Invokes callback with (element, index, array) for each assigned element and collects the return values into a new array at the same indexes.

Array.pop

function Array.pop() : Object

Returns

Returns the last element of the array if the array is not empty, otherwise returns undefined.

Description

Deletes and returns the last element of the array. If the array is empty, the function returns undefined and leaves the array unchanged.

Array.push

function Array.push(elem_n+1 : Object, ..., elem_n+m : Object) : Integer

Arguments

elem_n+1, ..., elem_n+m
The objects to append to the array.

Returns

The new length of the array.

Description

Appends a number of elements to the end of an Array.

Array.reduce

function Array.reduce(callback : Function) : Object
function Array.reduce(callback : Function, initial_value : Object) : Object

Returns

The final accumulator value.

Description

Invokes callback with (accumulator, element, index, array) for each assigned element, front to back. Without initial_value, the first element seeds the accumulator; on an empty array that is a runtime error.

Array.reduceRight

function Array.reduceRight(callback : Function) : Object
function Array.reduceRight(callback : Function, initial_value : Object) : Object

Returns

The final accumulator value.

Description

Like reduce, but iterates from the last element to the first.

Array.reverse

function Array.reverse()

Description

Reverses the order of the elements of the array.

Array.shift

function Array.shift() : Object

Returns

Returns the first element of the array.

Description

Deletes and returns the first element of the array and moves all the other elements down one place. If the array is empty, the function returns undefined and does not modify the array.

Array.slice

function Array.slice(start : Integer) : Array(Object)
function Array.slice(start : Integer, end : Integer) : Array(Object)

Arguments

start
The index of the element that will be the first element of the returned array.
end
The index of the first element that will not be included in the returned array.

Returns

A new array containing all elements of the array from start to end, including the start element, but excluding the end element.

Description

Returns a new array containing all elements of array with an index greater or equal than start and less than end in order. If start or end is negative, the result of adding this negative number to the length of the array is used. If end is not specified, all elements from the start to the end of the array are used. Note: slice() does not modify array.

Array.some

function Array.some(callback : Function) : Boolean
function Array.some(callback : Function, this_arg : Object) : Boolean

Returns

True if any callback returned a truthy value, else false.

Description

Invokes callback with (element, index, array) for each assigned element until the callback returns a truthy value.

Array.sort

function Array.sort() : Array(Object)
function Array.sort(compare_function : Function) : Array(Object)

Arguments

compare_function
A comparison function to be used for sorting. This function should take two arguments and return 1) a value less than zero if the first argument should appear before the second argument in the returned Array, 2) zero if it doesn't matter in which way the arguments appear in the returned Array, and 3) a positive number otherwise.

Returns

Returns the original array with the elements sorted.

Description

Sorts the array and returns it using the compare_function function. If compare_function is not specified, the elements are converted to Strings and sorted according to the character encoding. Undefined elements will appear at the end of the array.

Array.splice

function Array.splice(start : Integer) : Array(Object)
function Array.splice(start : Integer, length : Integer) : Array(Object)
function Array.splice(start : Integer, length : Integer, newElem_1 : Object, ..., newElem_k : Object) : Array(Object)

Arguments

start
The index of the first element that is to be replaced.
length
The number of elements that will be deleted from the array.
newElem_1, ..., newElem_k
Values that will be inserted into the array.

Returns

A new array containing the elements deleted from the array.

Description

Deletes and returns the length elements of the array after start, including the element at start. If length is not supplied, all elements after start will be deleted. If newElem_1, ..., newElem_k are supplied, they will be inserted at start after the deletion.

Array.toLocaleString

function Array.toLocaleString() : String

Returns

Returns a localized string that represents the array.

Description

Calls the function toLocaleString() on every element of the array and returns the results concatenated with a locale-specific separator.

Array.toString

function Array.toString() : String

Returns

Returns a string that represents the array.

Description

Converts each element of the array to a string, concatenates the elements using the "," as a separator, and returns a single concatenated string of the elements.

Array.unshift

function Array.unshift(newElem_1 : Object, ..., newElem_k : Object) : Integer

Arguments

newElem_1, ..., newElem_k
The values to insert at the beginning of the array.

Returns

Returns the new length of the array.

Description

Inserts newElem_1, ..., newElem_k at the beginning of array, shifts other elements forward accordingly, and returns the new length of the array.