Show Output
<!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"> <title>Create a New Empty Array in JavaScript</title> </head> <body> <script> var arr1 = [1,2,3,4,5]; // Reference arr1 by another variable var arr2 = arr1; // Making arr1 empty arr1 = []; document.write(arr1.length + "<br>"); // Prints: 0 document.write(arr2.length); // Prints: 5 </script> </body> </html>