Back to Functions

stubArray

util

This method returns a new empty array.

Installation

Import
import { stubArray } from '@tulx/utils';

Source Code

Implementation
/**
 * This method returns a new empty array.
 *
 * @returns Returns the new empty array.
 *
 * @example
 * ```ts
 * const arrays = times(2, stubArray);
 * console.log(arrays); // [[], []]
 * console.log(arrays[0] === arrays[1]); // false
 * ```
 */
export function stubArray(): unknown[] {
  return [];
}

Example

import { stubArray } from '@tulx/utils';

const arrays = times(2, stubArray);
console.log(arrays); // [[], []]
console.log(arrays[0] === arrays[1]); // false

Related Functions