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 length Property</h2> <p>The length property provides an easy way to append new elements to an array without using the push() method:</p> <p id="demo1"></p> <p id="demo2"></p> <script> const fruits = ["Banana", "Orange", "Apple", "Mango"]; document.getElementById("demo1").innerHTML = fruits; fruits[fruits.length] = "Kiwi"; document.getElementById("demo2").innerHTML = fruits; </script> </body> </html>