Show Output
<!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"> <title>JavaScript Add a New Element at the End of an Array</title> </head> <body> <script> var colors = ["Red", "Green", "Blue"]; colors.push("Yellow"); document.write(colors + "<br>"); // Prints: Red,Green,Blue,Yellow document.write(colors.length); // Prints: 4 </script> </body> </html>