JavaScript - Insert Elements at the Beginning of JS Array
To insert an element at the beginning of a JS array, the JavaScript unshift() method is used. [GFGTABS] JavaScript let a = [1,2,3,4] // Inserting element a.unshift(0) console.log(a) [/GFGTABS]Output[ 0, 1, 2, 3, 4 ] Table of Content Using Built-in MethodsWriting Your Own MethodUsing Built-in Methods