Run ❯
Get your
own
website
Result Size:
625 x 565
×
Change Orientation
Save Code
Change Theme, Dark/Light
Go to Spaces
<!DOCTYPE html> <html> <body> <h1>JavaScript Arrays</h1> <h2>The unshift() Method</h2> <p>The unshift() method returns the length of the new array:</p> <p id="demo1"></p> <p id="demo2"></p> <script> const fruits = ["Banana", "Orange", "Apple", "Mango"]; document.getElementById("demo1").innerHTML = fruits.unshift("Lemon"); document.getElementById("demo2").innerHTML = fruits; </script> </body> </html>