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