Skip to content

unshift

wolfram77 edited this page Mar 27, 2020 · 21 revisions

Adds values to the start.

Similar: push, pop, shift, unshift.

iterable.unshift(x, ...vs);
// x:  an iterable
// vs: values to add
// --> iterable
const iterable = require('extra-iterable');

var x = [3, 4].values();
[...iterable.unshift(x, 2)];
// [ 2, 3, 4 ]

[...iterable.unshift(x, 1, 2)];
// [ 1, 2, 3, 4 ]

references

Clone this wiki locally