Buffer

Buffer.concat()

Combines byte arrays into new storage in the supplied order. Tested on Node.js 22.16.0. A supplied length can truncate or zero-pad; avoid concatenating unbounded request bodies.

Formal Syntax & Structure

nodejs syntaxnodejs
Buffer.concat(list[, totalLength])

Parameters & Attributes

NameTypeDescription
listBuffer[] | Uint8Array[]Chunks in order.
totalLengthnumberOptional output byte count.

Return Value

Buffer

Combined bytes.

Working Example

Example Snippetnodejs
import { Buffer } from 'node:buffer';console.log(Buffer.concat([Buffer.from('book'), Buffer.from('s')]).toString());
Node.js Reference