Last Updated : Jan 1, 2023
We hope that you understand that article properly. Now, let us understand our today’s article in which we will show you how to declare an empty array.
As, there are many ways with the help of which you will understand how to declare an empty array.
Declaration of empty array is just to avoid pointless and incorrect calculation. We can also use length property to empty an array.
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta http-equiv="X-UA-Compatible" content="ie=edge"> <title>home page</title> </head> <body> <script> // for wider scope var arrayName=; // for local scope let arrayName=; //other ways are const array=; //or const myarray = new array; </script> </body> </html>
- First, we write <! DOCTYPE html> which we used as an instruction to the web browser about what version of HTML file is written in.
- Secondly, the <html> tag is used to indicate the beginning of an HTML document.
- As above now <head> tag is used to contain information about web page. In this tag a <title> tag is used which helps us to specify a webpage title. Both <head> and <title> tags are Paired tags. So, both have </head> and </title> ending tags respectively.
- Here, then we create a body tag. All the content which we want to show on browser’s screen or display is always written inside this codes.
- One thing to say here that there are many ways with the help of which we are able to create or declare an empty array.
- Here, inside body first we create script tag which is a paired tag and after that or say inside script tag, we create many types of arrays.
- Here, types mean that we declare arrays in many ways. For wider scope that syntax is different and for local scope the syntax is again different.
- Hence, we declare arrays in many forms. In next session, we will show you how to check arrays and it’s done with help of length. It means that we use length attribute to check the length of arrays.
- At last, the <body> and <html> tags are closed with </body> and </html> respectively.