0

<!DOCTYPE html>
<html>
<body>
<h1>JavaScript Arrays</h1>
<h2>The shift() Method</h2>

<p>The shift() method removes the first element of an array (and "shifts" the other elements to the left):</p>

<p id="workingcode1"></p>
<p id="workingcode2"></p>

<script>
const hero = ["Antman","Spiderman","Superman","Wonderwoman"];
document.getElementById("workingcode1").innerHTML = hero;
hero.shift();
document.getElementById("workingcode2").innerHTML = hero;
</script>

</body>
</html>

Output
JavaScript Arrays
The shift() Method
The shift() method removes the first element of an array (and "shifts" the other elements to the left):

Antman,Spiderman,Superman,Wonderwoman

Spiderman,Superman,Wonderwoman

Use of shift() Function in JavaScript
admin Changed status to publish December 19, 2023