JavaScript array.unshift() Function

JavaScript Logo

array.unshift() – Adds one or more elements to the **beginning** of an array and returns the new length.

๐Ÿ‘‰ Syntax

newLength = array.unshift(element1, ...);

๐Ÿงช Example

const arr=[2,3]; arr.unshift(1); // [1,2,3]

Comments