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