1
我在js文件中有一个外部客户端。外部JavaScript数组初始化
function client(Id,userName,code,type, firstName, SurName, address, phoneNum, Email)
{
this.Id = Id;
this.userName = userName;
this.code = code;
this.firstName=firstName;
this.SurName=SurName;
this.ddress=address;
this.phoneNum=phoneNum;
this.Email =Email;
this.clientAccounts = [];
this.addAccount = function(account)
{
this.clientAccounts.push(account);
};
}
我有一个html页面。在这里面我有一个脚本:
<script type="text/javascript">
var myClients =new Array();
myClients[0]= {firstName:"John", SurName: "Doe" ,Id:11,Password:1234, Address:"Some where over the rainbow", Pnumber:0523456789, Email:"[email protected]", Type: "regular"};
var account = new account(232, "young");
var deposit = new depositAccount(232, "young", 1000, 2555);
myClients[0].addAccount(deposit);
//clientAccounts.push(myClients[0]);
</script>
每个客户我初始化应该有多个帐户。现在我不确定如何设置客户端的帐户数组。它应该是构造函数的一部分(在括号内)? 因为现在我不能使用这个数组或获取它的数据(我试图使用另一个js文件)。
希望我明白你在问什么。 –
这应该是像oop。如何使阵列成为客户端的属性? – user2674835
myClients [0] .Accounts = [];你在找什么? –