Access array item from a function wrapper - Javascript Array Operation

Javascript examples for Array Operation:Array Index

Description

Access array item from a function wrapper

Demo Code

ResultView the demo in separate window

<html>
   <head></head>
   <body> 
      <script>
    var monthName = function( num ){
      var months = [/*w  ww  .  j  av a 2 s.  c o  m*/
        'Jan', 'Feb', 'Mar', 'Apr',
        'May', 'Jun', 'Jul', 'Aug',
        'Sep', 'Oct', 'Nov', 'Dec'
      ];
      return months[ num - 1 ];
    };
console.log( monthName( 6 ) );

      </script>  
   </body>
</html>

Related Tutorials