我正在尝试创建名为客户端的对象。并将其放入数组中。在此之后,读取第一个客户的名称。
例子:
client1 {nom : "marco", prenom : "chedel", adresseMail : "ssss@ggg.com"};
并将此客户端放入如下数组中。
listClients[client1]
我做了什么 :
var listClients = [];
var client1 = {nom : "chedel",prenom:"Marco",adresseMail:"marco@gmail.com"};
listClients.push(client1);
var client2 = {nom : "De Almeida",prenom:"Jorge",adresseMail:"jorge@gmail.com"};
listClients.push(client2);
function afficheClients(tableau){
for (i=0;i<tableau.length;i++)
{
var c = tableau[i];
document.write(c[adresseMail]);
// This ^^ doesn't work, it says :adresseMail isn't definied in c
}
}
afficheClients(listClients);