Skip to content

unshift

Subhajit Sahu edited this page Feb 3, 2021 · 21 revisions

Add values to the start.

Similar: push, pop, shift, unshift.


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

var x = [3, 4];
[...xiterable.unshift(x, 2)];
// → [2, 3, 4]

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


References

Clone this wiki locally