Table is a type of variable that stores an array of data (table rows).
Each row is a separate element of an array. It is an object whose properties are defined by the table’s columns. Read more about working with tables in Getting started with the Table data type.

Type parameters

Hierarchy

  • TTable

Properties

Readonly length

length: number

The TTable.length property returns the number of elements in an array.

The value of this property is an 32-bit unsigned integer that is always greater than the greatest index in the array.

Readonly result

result: R

String with the calculated result in the table.

In this string, the calculation of the total, the average, or the number of elements can be set.

Methods

concat

  • concat(...items: (T | ConcatArray<T>)[]): T[]
  • The method returns a new array that includes the array of table elements concatenated with other arrays and/or values passed as arguments.

    Important: the returned value is a regular array, not a table.

    Parameters

    • Rest ...items: (T | ConcatArray<T>)[]

    Returns T[]

    A new array containing all the elements.

delete

  • delete(index: number): void
  • The method deletes a specific row from a table.

    Parameters

    • index: number

    Returns void

every

  • every(predicate: function, thisArg?: any): boolean
  • The method tests whether at least one element in the array passes the test implemented by the callback function.

    Important: the method returns true when applied to an empty table, no matter the conditions.

    Parameters

    • predicate: function
        • (value: T, index: number, array: readonly T[]): unknown
        • Parameters

          • value: T
          • index: number
          • array: readonly T[]

          Returns unknown

    • Optional thisArg: any

    Returns boolean

    Returns true if the checking function returns true for each element of the table. Otherwise, returns false.

filter

  • filter(predicate: function, thisArg?: any): T[]
  • The method creates a new array consisting of all the elements that meet the conditions set in the callback function.

    Important: the returned value is a regular array, not a table.

    Parameters

    • predicate: function
        • (value: T, index: number, array: readonly T[]): unknown
        • Parameters

          • value: T
          • index: number
          • array: readonly T[]

          Returns unknown

    • Optional thisArg: any

    Returns T[]

    A new array with elements that met the conditions. If no elements meet the conditions, an empty array will be returned.

find

  • find(predicate: function, thisArg?: any): T | undefined
  • The method returns the value of the item in the table that is the first one to meet the conditions passed in the predicate function. Otherwise, it returns undefined.

    Parameters

    • predicate: function
        • (value: T, index: number, array: readonly T[]): unknown
        • Parameters

          • value: T
          • index: number
          • array: readonly T[]

          Returns unknown

    • Optional thisArg: any

    Returns T | undefined

findIndex

  • findIndex(predicate: function, thisArg?: any): number
  • The method returns an index in an array if the item meets the conditions set in the checking function. Otherwise, it returns -1.

    Parameters

    • predicate: function
        • (value: T, index: number, array: readonly T[]): unknown
        • Parameters

          • value: T
          • index: number
          • array: readonly T[]

          Returns unknown

    • Optional thisArg: any

    Returns number

forEach

  • forEach(callback: function, thisArg?: any): void
  • The method runs a callback function once for each element in a table.

    Parameters

    • callback: function
        • (value: T, index: number, array: readonly T[]): void
        • Parameters

          • value: T
          • index: number
          • array: readonly T[]

          Returns void

    • Optional thisArg: any

    Returns void

indexOf

  • indexOf(searchElement: T, fromIndex?: undefined | number): number
  • The method returns the first index that a given item can be found in the table, or it returns -1 if no such index exists.

    Parameters

    • searchElement: T
    • Optional fromIndex: undefined | number

    Returns number

insert

  • insert(index?: undefined | number): T
  • The method adds a new row to a table and returns a link to it.

    Parameters

    • Optional index: undefined | number

    Returns T

    A new table row.

join

  • join(separator?: undefined | string): string
  • The method concatenates all the elements in a string.

    Parameters

    • Optional separator: undefined | string

    Returns string

lastIndexOf

  • lastIndexOf(searchElement: T, fromIndex?: undefined | number): number
  • The method returns the last index that a given item in the table has. Or it returns -1 if no such index exists. The table is processed from the end to the beginning, starting with fromIndex.

    Parameters

    • searchElement: T
    • Optional fromIndex: undefined | number

    Returns number

map

  • map<U>(callback: function, thisArg?: any): U[]
  • The method creates a new array with the result of calling the function passed as the callback for each element in a table.

    Important: the returned value is a regular array, not a table.

    Type parameters

    • U

    Parameters

    • callback: function
        • (value: T, index: number, array: readonly T[]): U
        • Parameters

          • value: T
          • index: number
          • array: readonly T[]

          Returns U

    • Optional thisArg: any

    Returns U[]

    A new array with each element being the result of the callback function.

reduce

  • reduce(callback: function, initialValue?: T): T
  • reduce<U>(callback: function, initialValue?: U): U
  • The method applies the reducer function to each element of the table (from left to right) and returns a single resulting value.

    Parameters

    • callback: function
        • (previousValue: T, currentValue: T, index: number, array: readonly T[]): T
        • Parameters

          • previousValue: T
          • currentValue: T
          • index: number
          • array: readonly T[]

          Returns T

    • Optional initialValue: T

    Returns T

  • The method applies the reducer function to each element of the table (from left to right) and returns a single resulting value.

    Type parameters

    • U

    Parameters

    • callback: function
        • (previousValue: U, currentValue: T, index: number, array: readonly T[]): U
        • Parameters

          • previousValue: U
          • currentValue: T
          • index: number
          • array: readonly T[]

          Returns U

    • Optional initialValue: U

    Returns U

reduceRight

  • reduceRight(callback: function, initialValue?: T): T
  • reduceRight<U>(callback: function, initialValue?: U): U
  • The method applies a function against an accumulator and each value of the array (from right to left) to reduce it to a single value.

    Parameters

    • callback: function
        • (previousValue: T, currentValue: T, index: number, array: readonly T[]): T
        • Parameters

          • previousValue: T
          • currentValue: T
          • index: number
          • array: readonly T[]

          Returns T

    • Optional initialValue: T

    Returns T

  • The method applies a function against an accumulator and each value of the array (from right to left) to reduce it to a single value.

    Type parameters

    • U

    Parameters

    • callback: function
        • (previousValue: U, currentValue: T, index: number, array: readonly T[]): U
        • Parameters

          • previousValue: U
          • currentValue: T
          • index: number
          • array: readonly T[]

          Returns U

    • Optional initialValue: U

    Returns U

slice

  • slice(start?: undefined | number, end?: undefined | number): T[]
  • The method returns a new array containing a shallow copy of a portion of the initial array.

    Important: the returned value is a regular array, not a table.

    Parameters

    • Optional start: undefined | number
    • Optional end: undefined | number

    Returns T[]

    A new array containing the extracted table elements.

some

  • some(predicate: function, thisArg?: any): boolean
  • The method tests whether at least one element in the array passes the test implemented by the callback function.

    Important: the method returns false when applied to an empty table, no matter the conditions.

    Parameters

    • predicate: function
        • (value: T, index: number, array: readonly T[]): unknown
        • Parameters

          • value: T
          • index: number
          • array: readonly T[]

          Returns unknown

    • Optional thisArg: any

    Returns boolean

    Returns true if the checking function returns true for at least one element of the table. Otherwise, returns false.

toLocaleString

  • toLocaleString(): string
  • The method returns a string representing the elements of the table.

    Elements are transformed into strings with their own toLocaleString methods, and these strings are separated with a locale-specific string, for example, with a comma (,).

    Returns string

toString

  • toString(): string
  • The method returns a string representing the elements of the table.

    For a table, the toString() method concatenates elements of an array and returns one string containing all elements separated by commas.

    Returns string