实例代码“Ctrl+/”提示“F11/ESC”全屏 返回 格式化 恢复 运行
x
 
1
<!DOCTYPE html>
2
<html>
3
<head>
4
    <title>Array Type Example 9</title>
5
    <script type="text/javascript">
6
        var colors = new Array();                      //create an array
7
        var count = colors.push("red", "green");       //push two items
8
        alert(count);  //2
9
        
10
        count = colors.push("black");                  //push another item on
11
        alert(count);  //3
12
        
13
        var item = colors.pop();                       //get the last item
14
        alert(item);   //"black"
15
        alert(colors.length);  //2
16
    </script>
17
</head>
18
<body>
19
20
</body>
21
</html>