<HTML><Head><Metahttp-equiv= "Content-type"content= "text/html; charset=utf-8" /></Head><Body><Scripttype= "Text/javascript">Console.log ('the behavior of the Unshift () and Shift () methods is very similar to push () and pop (), unlike the insertion and deletion of elements in the head of an array rather than the tail. '); Console.log ('Unshift () adds one or more elements to the head of the array and moves the existing elements to a higher index to get enough space and finally returns the new length of the array. '); Console.log ('shift () deletes the first element of the array and returns it, and then moves all subsequent elements down one position to fill the empty array header. ');vara=[];varret=A.unshift (1); Console.log ('a.unshift (1) a='+a+': ret='+ret); RET=A.unshift ( A); Console.log ('A.unshift (a=)'+a+': ret='+ret); A.shift (); Console.log ('a.shift () a='+a+': ret='+ret); A.unshift (3,[4,5]); Console.log ('A.unshift (3,[4,5]) a='+a+': ret='+ret); A.shift (); Console.log ('a.shift () a='+a+': ret='+ret); A.shift (); Console.log ('a.shift () a='+a+': ret='+ret); A.shift (); Console.log ('a.shift () a='+a+': ret='+ret);</Script></Body></HTML>
JavaScript unshift () and Shift ()