The simple Array in JavaScript:- Geniusofstudent

  • The Array object can store multiple values in a single variable.
  • The array values are accessed by using its index value.


 
Code:-
  • <!DOCTYPE html> 
    1. <html> 
    2.  
    3. <head> 
    4.  <meta name="viewport" content="width=device-width, initial-scale=1"> 
    5. </head> 
    6.  
    7. <body> 
    8.  <h1>Simple Array</h1> 
    9.  
    10.  <h2>var ar=[10,20,30];</h2> 
    11.  
    12.  <input type="button" onclick="ar_fun();" value="Get Array Value"> 
    13.  
    14.  <script> 
    15.   function ar_fun() 
    16.   { 
    17.  
    18.    var ar = [10, 20, 30]; 
    19.  
    20.    alert(ar[0]); //Display 10 
    21.    alert(ar[1]); //Display 20 
    22.    alert(ar[2]); //Display 30 
    23.  
    24.   } 
    25.  </script> 
    26.  
    27. </body> 
    28.  
    29. </html>

    The simple Array in JavaScript:- Geniusofstudent The simple Array in JavaScript:- Geniusofstudent Reviewed by Network security on July 11, 2019 Rating: 5

    No comments:

    Useful Information

    Powered by Blogger.