Question:Briefly describe JavaScript core Array method shift() with an example. 

Answer Array.shift() method removes the first element in an array and returns it.Example:
var stackWork=new Array("Lenny","Harold","Mary","Jean","Sal");
  var item=stackWork.shift();
  document.write(item);
  document.write("<br/>")
  document.write(stackWork);
Output: Lenny Harold,Mary,Jean,Sal,Delia 

+ Report
Total Preview: 955
Briefly describe JavaScript core Array method shift() with an example.
Copyright © 2024. Powered by Intellect Software Ltd