Reading and Modifying the Contents of an Array - Javascript Language Basics

Javascript examples for Language Basics:Introduction

Introduction

You read the value at a given index using square braces and ].

JavaScript uses zero-based array indexes.

Reading Data from an Array Index

Demo Code

ResultView the demo in separate window

<!DOCTYPE HTML>
<html>
    <head>
        <title>Example</title>
    </head>
    <body>
        <script type="text/javascript">
            var myArray = [100, "java2s.com", true];
            document.writeln("Index 0: " + myArray[0]);
        </script>
    </body>
</html>/*from w ww  .j av a2 s .c  o  m*/

Related Tutorials