- The Array object can store multiple values in a single variable.
- The array values are accessed by using its index value.
Code:-
- <html>
- <head>
- <meta name="viewport" content="width=device-width, initial-scale=1">
- </head>
- <body>
- <h1>Simple Array</h1>
- <h2>var ar=[10,20,30];</h2>
- <input type="button" onclick="ar_fun();" value="Get Array Value">
- <script>
- function ar_fun()
- {
- var ar = [10, 20, 30];
- alert(ar[0]); //Display 10
- alert(ar[1]); //Display 20
- alert(ar[2]); //Display 30
- }
- </script>
- </body>
- </html>
The simple Array in JavaScript:- Geniusofstudent
Reviewed by Network security
on
July 11, 2019
Rating:
No comments: