Home > @josh-brown/vector > Vector > combine
Constructs a vector by combining the values of two other vectors
Signature:
combine(other: Vector<S>, combineEntries: (a: S, b: S) => S): Vector<S>;|
Parameter |
Type |
Description |
|---|---|---|
|
other |
Vector<S> |
The vector with which to combine this one |
|
combineEntries |
(a: S, b: S) => S |
A function which takes an entry from each vector and returns a new entry |
Returns:
Vector<S>
The new vector
const first = vec([1, 2, 3]);
const second = vec([2, 3, 4]);
const combined = first.combine(second, (a, b) => a * b);
// [2, 6, 12]