UNPKG

@extra-array/unshift

Version:
53 lines (39 loc) 1.64 kB
Adds values to the start. [:package:](https://www.npmjs.com/package/@extra-array/unshift) [:smiley_cat:](https://github.com/orgs/nodef/packages?repo_name=extra-array) [:running:](https://npm.runkit.com/@extra-array/unshift) [:vhs:](https://asciinema.org/a/332151) [:moon:](https://www.npmjs.com/package/@extra-array/unshift.min) [:scroll:](https://unpkg.com/@extra-array/unshift/) [:newspaper:](https://nodef.github.io/extra-array/) [:blue_book:](https://github.com/nodef/extra-array/wiki/) > Alternatives: [unshift], [unshift$].<br> > Similar: [push], [pop], [shift], [unshift]. > This is part of package [extra-array]. [extra-array]: https://www.npmjs.com/package/extra-array <br> ```javascript array.unshift(x, ...vs); // x: an array // vs: values to add ``` ```javascript const array = require("extra-array"); var x = [3, 4]; array.unshift(x, 2); // [ 2, 3, 4 ] array.unshift(x, 1, 2); // [ 1, 2, 3, 4 ] ``` <br> <br> ## References - [Array.prototype.unshift: MDN web docs](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/unshift) - [array_unshift: PHP](https://www.php.net/manual/en/function.array-unshift.php) - [Array.unshift: Ruby](https://ruby-doc.org/core-2.5.0/Array.html#method-i-unshift) - [immutable-iterable-prototype: @azu](https://github.com/azu/immutable-iterable-prototype) [unshift]: https://github.com/nodef/extra-array/wiki/unshift [unshift$]: https://github.com/nodef/extra-array/wiki/unshift$ [push]: https://github.com/nodef/extra-array/wiki/push [pop]: https://github.com/nodef/extra-array/wiki/pop [shift]: https://github.com/nodef/extra-array/wiki/shift