Skip to content

concat

Flattens and filters nullish values from arguments

130 bytes
since v12.5.0

Usage

The concat function combines multiple values and arrays into a single array, while:

  • Flattening nested arrays one level deep
  • Filtering out null and undefined values
  • Preserving the type information of the remaining values

Other falsy values (e.g. 0, false, '', NaN) are preserved.

import {
function concat<T extends readonly [any, any, ...any[]]>(...values: T): Concat<T>

Flattens and filters nullish values from arguments, returning a new array containing only the non-nullish elements. Nested arrays are flattened one level deep.

@seehttps://radashi.js.org/reference/array/concat

@example

const result = _.concat('', ['a'], undefined, [null, 'b'])
// => ['', 'a', 'b']

@example

const result = _.concat(1, [2, [3]], null)
// => [1, 2, [3]] // Note: only flattens one level

@version12.5.0

concat
} from 'radashi'
const
const result: string[]
result
=
concat<[string, null, (string | undefined)[], string]>(values_0: string, values_1: null, values_2: (string | undefined)[], values_3: string): string[]

Flattens and filters nullish values from arguments, returning a new array containing only the non-nullish elements. Nested arrays are flattened one level deep.

@seehttps://radashi.js.org/reference/array/concat

@example

const result = _.concat('', ['a'], undefined, [null, 'b'])
// => ['', 'a', 'b']

@example

const result = _.concat(1, [2, [3]], null)
// => [1, 2, [3]] // Note: only flattens one level

@version12.5.0

concat
('a', null, ['b',
var undefined
undefined
], 'c')
// => ['a', 'b', 'c']