实例代码“Ctrl+/”提示“F11/ESC”全屏 返回 格式化 恢复 运行
x
 
1
<!DOCTYPE html>
2
<html>
3
<head>
4
    <title>Array Type Example 8</title>
5
    <script type="text/javascript">
6
        var person1 = {
7
            toLocaleString : function () {
8
                return "Nikolaos";
9
            },
10
            
11
            toString : function() {
12
                return "Nicholas";
13
            }
14
        };
15
        
16
        var person2 = {
17
            toLocaleString : function () {
18
                return "Grigorios";
19
            },
20
            
21
            toString : function() {
22
                return "Greg";
23
            }
24
        };
25
        
26
        var people = [person1, person2];
27
        alert(people);                      //Nicholas,Greg
28
        alert(people.toString());           //Nicholas,Greg
29
        alert(people.toLocaleString());     //Nikolaos,Grigorios
30
31
    </script>
32
</head>
33
<body>
34
35
</body>
36
</html>