实例代码“Ctrl+/”提示“F11/ESC”全屏 返回 格式化 恢复 运行
x
 
1
<!DOCTYPE html>
2
<html>
3
<head>
4
    <title>Array Type Example 5</title>
5
    <script type="text/javascript">
6
        
7
        var colors = ["red", "blue", "green"];    //creates an array with three strings
8
        colors[colors.length] = "black";          //add a color
9
        colors[colors.length] = "brown";          //add another color
10
11
        alert(colors.length);    //5
12
        alert(colors[3]);        //black
13
        alert(colors[4]);        //brown
14
15
    </script>
16
</head>
17
<body>
18
19
</body>
20
</html>